Skip to main content
gamedev.net
🔒 Locked

trig functions

Started by luridcortex 1 reply 250+ views
Original Post
luridcortex
luridcortex
Im not sure what it is about these trig functions that im not understanding, ive got a trig book, 2 books with a trig review section, and have visited trig sites - yet i still could not tell you what cos, sin, ect.. actually do and why they are usefull. I see them used places and i dont understand why, or what they actually do. Take this peice of code for example - it rotates a sphere in a circle while fixed on the y-axis. sphere1angle += AngleInc; float x1 = cos( sphere1angle ) * CircleRadius; float z1 = sin( sphere1angle ) * CircleRadius; sphereModel.SetLocation( x1, 0.0f, z1 ); sphereModel.Render(); I know the code works, but i dont understand how sin and cos make the code work. (unfortunatley i did not take trig in high school :\ )
HellRiZZer
HellRiZZer
Well, if you don''t know basics behind sin and cos (and other trig functions) I''d suggest you read some book on trigonometry.

If you just forgot it, here is the reminder.
You got a right-angle triangle like this:
A
|*
| *
| *
| 90 a *
|------------*
B C

sin of angle a (sin(a)) is AB/AC, while cos(a) is BC/AC


In a circle, when you increase angle from 0 towards 360, sin(a) acts as x position and cos(a) acts as y position (see cos(a) and sin(a) for a = 0 to 360 degrees values).
That''s basically all.



" Do we need us? "


Ionware Productions - Games and Game Tools Development

LilBudyWizer
LilBudyWizer
The main thing with sine, cosine and tangent is they are the ratios of the sides of a right triangle.



That being freely stolen from MathWorld. The diagram summarizes what you really have to remember with trig. The rest of trig is basically just identities dealing with those simple relationships. All of those identities can be derived from those simple relationships assuming you know your geometry. That may be more your problem than actual trig. Once you have a few identities you can start using algrebra to derive more identities, but the first few have to be done geometrically. As an example what is the cos(s+t). Without any other identities it takes a geometric construction to derive it.



Once again stolen image. It isn't he exact construction you need to make it clear what the formula would be, but it does serve to show why geometry is important to trig. If you are having trouble with trig I would suggest you review your geometry.

[edited by - LilBudyWizer on February 25, 2003 2:56:58 AM]
Keys to success: Ability, ambition and opportunity.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.