Game Development Reference
In-Depth Information
to recognize situations for which the dot product is the correct tool for the
job; sometimes it helps to have other interpretations pointed out, even if
they are “obviously” equivalent to each other.
Consider the right triangle on the
right-hand side of Figure 2.25. As
the figure shows, the length of the
hypotenuse is 1 (since b is a unit
vector) and the length of the base is
equal to the dot product a b . From
elementary trig (which was reviewed
in Section 1.4.4), remember that the
cosine of an angle is the ratio of the
length of the adjacent leg divided by
the length of the hypotenuse. Plug-
ging in the values from Figure 2.25,
we have
Figure 2.25
Interpreting the dot product by using the
trigonometry of the right triangle
hypotenuse = a b
adjacent
= a b .
cosθ =
1
In other words, the dot product of two unit vectors is equal to the cosine
of the angle between them. This statement is true even if the right triangle
in Figure 2.25 cannot be formed, when a
b
≤ 0 and θ > 90 o . Remember
that the dot product of any vector with the vector x = [1,0,0] will simply
extract the x-coordinate of the vector. In fact, the x-coordinate of a unit
vector that has been rotated by an angle of θ from standard position is one
way to define the value of cosθ. Review Section 1.4.4 if this isn't fresh in
your memory.
By combining these ideas with the previous observation that scaling
either vector scales the dot product by the same factor, we arrive at the
general relationship between the dot product and the cosine.
Dot Product Relation to Intercepted Angle
The dot product of two vectors a and b is equal to the cosine of the an-
gle θ between the vectors, multiplied by the lengths of the vectors (see
Figure 2.26) . Stated formally,
a b = a b cosθ.
(2.4)
Search WWH ::




Custom Search