PDA

View Full Version : Cosinus and Sinus, my whorst enemies



Dr. Crap, PHD
02-21-2000, 06:35 AM
As you might have suspected, I'm not a real doctor.
I'm new to 3D coding and have just begun a search for the best 3D API available. Now that I have found OpenGL, I find myself with another problem. Cosinus and Sinus are two mathematical functions wich are used in 3D Graphics extensively, yet I don't understand what exactly they do. I feel that once I master this, I will know how to draw spherical and circular objects in OpenGL, and be able to rotate objects in 3D on the screen. I never whent to school, so it's not realy something I could have done something about. Can someone, anyone, give me a brief explanation of what exactly the use is of these two functions, and why they keep popping up in 3D code?
Thank you.

Rob
02-21-2000, 08:54 AM
I assume you meant sines and cosines?
Certainly this is a fundamental issue which is just one of many that you're going to have to get your head around to do 3D programming (the other BIGGIE is matrix math).
Here's one way to understand it:
sine, cosine and tangent are 3 trigonometry functions which relate angles and lengths of sides of a right triangle and are defined this way
T = the angle of interest
A = side of triangle Adjacent to T
O = side of triangle Opposide T
H = the hypotenuse (sp?) (angle opposite the right angle).
````````/|`````
```````/`|`````
``````/``|`````
``H``/```|`````
````/````|`O```
```/`````|`````
``/``````|`````
`/`)T````|`````
---------+`````
`````A`````````
cos(T) = A/H
sin(T) = O/H
tan(T) = O/A
These functions are useful for all sorts of things. For example if you want to break an arbitrary vector up into x and y components, you find the angle the vector makes with the x-axis of your coordinate system and H = length of the vector and you get:
x_component_of_H = A = H*cos(T)
y_component_of_H = O = H*sin(T)

I hope that's a decent start for you.

-Rob

[This message has been edited by Rob (edited 02-21-2000).]

[This message has been edited by Rob (edited 02-21-2000).]

Dr. Crap, PHD
02-21-2000, 12:41 PM
It most certainly is!
Thank you very much Rob!!!

02-29-2000, 06:46 PM
Check this site out, I think you may find it quite handy.

http://mathworld.wolfram.com/

If you are just looking to find co-ordinates to generate surfaces with then look up the parametric equation for the shape in question.

eg.

The parametric equations for a circle of Radius r is

x = r*cos(theta)
y = r*sin(theta)

Unfortunately most really interesting shapes are not so easily generated and you have to use meshes to render them. Which means creating code to load objects.