views:

112

answers:

4

Hello,

I know that sin is opposite/hypotenuse in a right angled triangle and cos is adjacent/hypotenuse. But when i come across functions like for Eg. In Flash :-

something.x = Math.cos(someNumber) * someotherNumber;

something.z = Math.sin(someNumber) * someotherNumber;

what does it actually do? My stack overflows when i see such things. I don't understand trignometry that well. What is the opposite and what exactly is the hypotenuse in the above lines? And why does it use cos on one line and sin on other? Is there any shortcut for calculating these kind of things? Please help me. These things i didn't understand even when i took computer graphics classes and unfortunately even when i asked to my lecturer, she always used to tell, these things you already studied when you were in 7th grade. But i really don't remember that i studied anything like this.

Thanks in advance :)

+7  A: 

I recommend you read the Wikipedia entry on the unit circle.

In short, if you are looking for the coordinates of a point located on a circle of radius 1 at a given counter-clockwise angle from the right-most point of the circle, its y coordinate will be given by the sine of this angle, and its x coordinate will be given by the cosine of this angle.

If your circle has a radius of something other than 1, you must multiply by that radius, hence the *someotherNumber in your equations.

Kena
+2  A: 

http://cda.morris.umn.edu/~mcquarrb/Precalculus/Animations/SineCosineAnim.html

The sine and cosine functions are often used to calculate a coordinate for a point of which you know the distance and the angle.

Sjoerd
+1  A: 

You've asked two questions:

1) What is the opposite and what exactly is the hypotenuse in the above lines?

First of all, someNumber is going to represent an angle measured in radians. The cos and sin values represent the sine and cosine of that angle. Usually, we think of a triangle with hypotenuse 1, so that cosine and sine become like (x,y) co-ordinates in a plane.

2) What does it actually do?

Although you may think of sine and cosine as something you would need to know the length of three sides of a triangle to calculate, there are methods to calculate them using ordinary arithmetic (addition, subtraction, multiplication, division). When the code is executed, some such method is likely used to perform the calculation. Here is one of the most famous examples: http://en.wikipedia.org/wiki/Taylor_series

Rice Flour Cookies
+1  A: 

The sine and cosine functions have been generalised for all real values. See:

http://en.wikipedia.org/wiki/Trigonometric_functions#Unit-circle_definitions

This is what is computed by the those calls.

donatello