Free JavaScript Editor Ajax Editor

↑

Main Page

## TrigonometryTrigonometry is the study of angles, shapes, and their relationships. Most trigonometry is based on the analysis of a right triangle, as shown in Figure C.1. ## Figure C.1. The right triangle.Table C.1 lists the radian/degree values. Here are some trigonometric facts: Fact 1:
There are 360 degrees in a complete circle, or 2*PI radians. Hence, there are PI radians in 180 degrees. The computer functions Fact 2: The sum of the interior angles theta1 + theta2 + theta3 = 180 degrees or PI radians. Fact 3: Referring to the right triangle in Figure C.1, the side opposite theta1 is called the opposite side, the side below it is called the adjacent side, and the long side is called the hypotenuse. Fact 4: The sum of the squares of the sides of a right triangle equals the square of the hypotenuse. This is called the Pythagorean theorem. Mathematically, it's written like this: hypotenuse Or sometimes it's written using c Therefore, if you know two sides of a triangle, you can find the third. Fact 5: There are three main trigonometric ratios that mathematicians like to use: sine, cosine, and tangent. They are defined as DOMAIN: 0 <= theta <= 2*PI RANGE: -1 to 1 DOMAIN: 0 <= theta <= 2*PI RANGE: -1 to 1 DOMAIN: -PI/2 <= theta <= PI/2 RANGE: -infinity to +infinity Figure C.2 shows graphs of all the functions. Notice that they're all periodic (repeating) and that sin(theta) and cos(theta) have periodicity of 2*PI, while tangent has periodicity of PI. Also, notice that tan(theta) goes to +-infinity whenever theta mod PI is PI/2. ## Figure C.2. Graphs of basic trigonometric functions.NOTE You may note the use of the terms domain and range. They simply mean the input and the output, respectively. Now, there are about a gazillion trigonometric identities and tricks, and it would take a math book to prove them all. I'm just going to show you the ones that a game programmer should know. Table C.2 lists some trigonometric ratios as well as some neat identities.
Of course, you could derive identities until you turned many shades of green. In general, identities help you simplify complex trigonometric formulas into simpler ones so you don't have to do the math. Hence, when you come up with an algorithm based on sin, cos, tan, and so on, always take a look in a trigonometry book to see whether you can simplify your math so that fewer computations are needed to get to the result. Remember: speed, speed, speed!!! |

↓

Ajax Editor JavaScript Editor