• Advertisement

Archived

This topic is now archived and is closed to further replies.

What exactly is Sin, Cosine, and tangent and what are they used for?

This topic is 5836 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I know this may sound very stupid but in all honesty i have no idea what these things are and how and why they are used in games can someone plz enlighten me ty "Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
They are trigonometric functions that you can use to find missing parts of a triangle. So if you have 2 sides of a triangle and one angle, you can figure out the other 2 angles and the other side.

Share this post


Link to post
Share on other sites
Those are transcendental functions used for relating the various angles and sides of a triangle - aka Trigonometry. For best results consult on online math web site. Sorry, don''t have a link handy, but I''m sure someone else will provide one here soon.

Share this post


Link to post
Share on other sites
but why are they used in games...
i mean when would you ever need to use this in a game, ive seen cos being used for wavy effects(nehe tuts) but wouldnt you know everything you need to know about the triangles you created

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
I tend to find them most useful when dealing with a game that involves a player or object like the ship in asteroids. The ship has some angle "a" expressed in radians. But when you accelerate, you need to know how much velocity to add to the x and y components of the velocity. That''s where sin and cos come in.


dx=dx + cos(a)
dy=dy - sin(a)


(I use "-sin" instead of "+sin" because computers'' coordinate systems are upside-down compared to mathematical coordinate systems.)

It''s also handy in drawing a circle

begin loop a from 0 to pi*2 (in small steps)
draw point at (CenterX + cos(a) * radius,
CenterY - sin(a) * radius)
Next a


"All you need to do to learn circular logic is learn circular logic"

Share this post


Link to post
Share on other sites
that site lost me on the fourth of fifth page ><

this paragraph especially confused me:

The other common measurement for angles is radians. For this measurement, consider the unit circle (a circle of radius 1) whose center is the vertex of the angle in question. Then the angle cuts off an arc of the circle, and the length of that arc is the radian measure of the angle. It is easy to convert between degree measurement and radian measurement. The circumference of the entire circle is 2 ( is about 3.14159), so it follows that 360° equals 2 radians. Hence, 1° equals /180 radians, and 1 radian equals 180/ degrees.

what in blazes is this dude talking about?

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Wait until your high school trig course. This will all be understandable then.

If you don''t know why you need cosine, chances are you aren''t doing anything that requires it.

Share this post


Link to post
Share on other sites
well in the nehe tuts ive seen sin and cos and i would like to know what they are for and when and how to use them

i mean isnt trigonometry just for triangles???

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
what is meant by an arc of a circle and arc length?
maybe if i knew these things i would be better able to understand the site that was given

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
quote:
Original post by SonShadowCat
i mean isnt trigonometry just for triangles???

An unfortunate, but popular, misconception. Sine, Cosine, etc are actually circular functions, which explains their usefulness in relating object rotations. They are also periodic functions (in part because they are circular), meaning that for the period P, Sin(x) = Sin(x + nP) (x being any arbitrary value and n being any integer - positive or negative). These properties make Sine and Cosine very useful functions.

Why do they show up in game programming? Game programming is often a series/collection of abstractions/approximations of real-life circumstances/phonomena. The Sine wave describes the motion of all fundamental waveforms - light, sound - all electromagnetic particles. It''s a lot of stuff over your head right now, but rest assured that those functions are very important (and you will come to know them well when you take Calculus).

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! ]
Thanks to Kylotan for the idea!

Share this post


Link to post
Share on other sites
[stupid]
Umm what does arbitrary mean?
[/stupid]

Um if i wait till i take trig and cal in school then ill never get anywhere in programming will I?

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
It''s never too late or too early to learn this stuff. I figure you''re already ahead of the curve by even *wanting* to learn trig before it''s forced upon you in school. You''ll probably pick it up quicker than other students if you can recognize real, practical applications for what you''re learning. I wish I''d discovered game programming before I took trig in HS.

If you really want to get into it now, I''ve found most (but not all) online math resources to be all about application ("To rotate a cube, use these functions. Trust me." me: copy, paste) and low on explanations. Maybe an entry-level textbook would help. Anybody have any suggestions? I''d go to amazon.com, search for trig books and read the customer comments. If you don''t know anything about algebra I''d start there or some of the notation will be hard to follow.

Share this post


Link to post
Share on other sites
i would love to buy books on the subject but i have no money
im gonna do a search for trig tuts that make sense -.-

is there anything i need to know besides basic algebra before tackling trig?

if i dont find explanations then its never going to enter my when i need to use sin, cos, etc

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
SOHCAHTOA is all you really need!

Share this post


Link to post
Share on other sites
lol i just learned that today in math

teachers these days dont really know much, theyre like robots, they say what theyve been told to say( no offense to the good teachers out there)

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
ok can someone plz explain this little part to me:

r=(8)/(pi/3)

which then equals 24/pi

how did that come up?

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
I havn''t taken a trig class either. What tought me how to use the trig functions is the website below:

http://echellon.hybd.net/issues/5/articles/circle/sincos.htm

It focuses on game developers by giving examples like car turning and stuff. It describes the waves(as could be used in a flag) and all kinds of stuff you might want to know. I believe the title of the article is Sin and Cosine for Game Developers.

[Edited by - kmsixpence on October 17, 2005 7:34:20 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
quote:
Original post by SonShadowCat
ok can someone plz explain this little part to me:

r=(8)/(pi/3)

which then equals 24/pi

how did that come up?




Go back and read your 6th grade math text again, where they go over ''division of fractions.''

Share this post


Link to post
Share on other sites
thx alot!
im gonna read it after i do my homework and run some errands

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
I''m not sure if you don''t understand where r=(8)/(pi/3) comes from or what. I''m not sure what you are referring to. But it equals 24/pi because r=(8)/(pi/3)= 8 * (3/pi) = 24/pi.

One of the most important uses for trig is a 3d rotation for many games. Because on the screen, we can only use x and y coordinates, but often need to also use angles, sin,cos and tangent function provide the relations.

Share this post


Link to post
Share on other sites
well the sixth grade was quite a while ago and i dont remember it having a fraction dividing by a fraction -.-

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
quote:
Original post by SonShadowCat
but why are they used in games...
i mean when would you ever need to use this in a game, ive seen cos being used for wavy effects(nehe tuts) but wouldnt you know everything you need to know about the triangles you created

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday



Yeah with this Direct3D and OpenGL stuff it''s all so easy, but you should know that to draw all these things in 3D, the computer needs a lot of trigonometric operations.

If you''d write a complete software 3D engine from scratch yourself, you''d certainly need them.

Share this post


Link to post
Share on other sites
uhh how did a division problem turn into a multiplication one?
sorry if i sound stupid but i am honestly confused

"Those who serve no purpose, have no purpose."- SSC the Super Saiyan Cat

Edited By - SonShadowCat on Your Girlfriends Birthday

Share this post


Link to post
Share on other sites
When you divide one number by another, you are in effect multiplying it by the reciprical. Take this case:

10/2 = 5
10 * 1/2 = 5

**Note, realize that 2 is also equal to 2/1

So if you have 8/(pi/3) ''flip'' the fraction in the denominator and multiply:

8 * (3/pi)

Share this post


Link to post
Share on other sites

  • Advertisement