CONTENTS Graphs: sine, cosine and tangent OTHER MATERIAL |
Trigonometrysine, cosine and tangent Trigonometry is the branch of geometry dealing with relationships between the sides and angles of triangles. As we discussed earlier, vectors define right triangles. So we can use the trigonometric functions with vectors. The core trigonometric functionssuch as sine, cosine, and tangentderive their meaning from ratios of the sides of a right triangle. When considering angle A in a right triangle, as shown, the functions are: The sine of angle A equals the length of the side opposite the angle divided by the length of the hypotenuse. The angle's cosine and tangent are defined similarly. You may find it easier to remember these relationships with the mnemonic "Sohcahtoa": In Javascript, the trigonometric functions are methods belonging to the 'Math' object (case-sensitive), which is global. So they are written: Math.sin(angle) Each of these functions returns a number (scalar). The return values for sine and Cosine range from -1 to 1; tangent's range is ± infinity. Radians The trigonometric methods in Javascript expect you to give them angles measured in radians, not degrees. A radian is simply a different unit, a different way to measure angles. Specifically, a radian is the size of the angle in a circle subtended by an arc equal in length to the circle's radius. That is: Because the circumference of a circle is 2PI*radius, there are 2PI radians in a complete revolution: 360° equals 2PI radians. So 1 radian is slightly more than 57 degrees. Unfortunately, most of After Effects' parameters measure angles in degrees, not radians. So you'll often need to convert between the different units. You could do this with the exchange ratio listed abovebut because these conversions are so common, After Effects includes two functions that make it much easier: radians_to_degrees(angle) For instance, this line would calculate the sine of the current layer's rotation: Math.sin(degrees_to_radians(rotation)); The expression first converts rotation from degrees to radians, and passes the results to Math.sin(). Finding the Length of an Unknown Side One use for the trigonometric functions is to find the length of an unknown side of a right triangle, when we know the length of one side and the size of one angle. (We can use the Pythagorean Theorem to find the length of one side if we know the lengths of the other two sides.) Because the trigonometric functions are defined as ratios of the sides of a right triangle, simple algebra lets us define each side in terms of the functions: opposite = hypotenuse*sin(A) We'll put these relationships to practical use soon. For now, though, we'll just use these equations to point out some characteristics of these functions. For instance, you can notice from the first equation that there are two ways for the opposite to get larger: increase the hypotenuse, or increase the sine of angle A. Similarly, to increase the adjacent side, we must increase either the hypotenuse or the cosine of angle A. We know from experience and from the Pythagorean Theorem that the two perpendicular sides of a right triangle have an inverse relationship. An increase in one is met by a decrease in the otherunless of course the hypotenuse also increases. It follows from this that sine and cosine also have inverse relationships: opposite gets bigger, adjacent gets smaller // Substitute above definitions for opposite &
adjacent // We can cancel hypotenuse from both sides, leaving So, from the equations listed above we can see that sine and cosine have inverse relationships. In fact, they define the inverse relationship between the opposite and adjacent. We discuss the nature of this relationship in the next section.
|
Entire contents © 2001 JJ Gifford.