Sine, Cosine, and Tangent
Another concept to dig around in the dredges of your memory from high school trigonometry class is the three triangle operations: sine, cosine, and tangent. If you haven’t thought about these concepts since you took the SATs, you may be a little foggy on them. Figure 4.6 illustrates an example of the triangle operations. In this section, we discuss what they mean and how they can help you to do neat things in graphics programming.
Every triangle that is not an equilateral triangle or a scalene triangle has one side that is longer than the others. This side is the hypotenuse, which is important because many of the operations performed in graphics programming are based in trigonometric functions involving the hypotenuse. In most of your vector operations, you will be working under the assumption that the vector is the hypotenuse of a triangle.
A mnemonic device may help you remember how to find the sine, cosine, and tangent: SOH CAH TOA. It translates to
Sine: Opposite divided by hypotenuse
Cosine: Adjacent divided by hypotenuse
Tangent: Opposite divided by adjacent
Figure 4.6 Sine, cosine, and tangent operations
To get the normalized coordinates, you divide each component by the length. Think back to the description of how to normalize the coordinates of a vector: You divide each side by the length of the hypotenuse, which results in the hypotenuse equaling 1. An added bonus is that this operation also gives you both the sine and cosine of the triangle. This knowledge will be especially useful when you get to the section “Transformations: Scale, Translation, Rotation, Projection.”