Game Development Reference
In-Depth Information
triangle based on the angle we
re interested in; in this case A .The
vertical side of the triangle is opposite (opp) angle A ,whilethe
The aforementioned trig functions work with these sides as
follows:
￿
'
90 °
The sine of an angle is equal to the opposite side
'
s length
A
divided by the hypotenuse
'
s length: sin A = opp/hyp
￿
The cosine of an angle is equal to the adjacent side
'
s length
Figure 11.3 The three
sides of a right triangle,
related to angle A.
s length: cos A = adj/hyp
￿ The tangent of an angle is equal to the opposite side divided by
As you can see, these functions are very helpful if you only know
a little bit of information about a triangle and need to determine the
other components. Let
divided by the hypotenuse
'
s look at a few examples. In Fig. 11.4 ,we
know the value of angle A is 50
'
°
(and by extension, the other
missing angle would then be 40
°
). We also know the length of the
hypotenuse is 30.
To find the lengths of the other two sides, we rewrite the sine
and cosine equations as follows:
90 °
A = 50 °
=
cos A
×
= ð
cos 50
Þ ×
30
opp
=
sin A
×
hyp ,or opp
= ð
sin 50
Þ ×
30
Figure 11.4 Using the
angle and one side,
we can use the trig
functions to find the
values of the other
two sides.
If you used a calculator with the trig functions on it, you would
quickly determine that the value of the adjacent side is ~19.3 and
the value of the opposite side is ~23.
In Fig. 11.5 , we can see that we now know one angle (45
°
)and
the length of the side opposite that angle (20
).
Once again, we simply manipulate the equations to determine
the other two sides, this time using tangent instead of cosine, since
cosine has nothing to do with the opposite side:
°
hyp
=
opp / sin A ,or hyp
=
20/
sin 45
Þ
ð
=
opp / tan A ,or adj
=
20/
ð
tan 45
Þ
Using a calculator, this would reveal the hypotenuse to have a
length of ~28.3 and the adjacent side to also be 20.
Now let
90 °
A = 45 °
s look at an example ( Fig. 11.6 ) with a triangle where
we know the lengths of the two shorter sides, but no angles and no
hypotenuse.
Since we know the opposite and adjacent sides, the obvious
choice would be to use the tangent equation to determine the value
of angle A (and flipping the two sides to find out the value of B ):
'
Figure 11.5 A triangle
where we know one
angle and one side.
tan A
=
15/20
tan B
=
20/15
re stuck. We want the values of A and B ,not
the tangent of A and B . Luckily, there is a way to reverse each trig
However, now we
'