Game Development Reference
In-Depth Information
What does it mean to measure the an-
gle between two vectors in 3D? Any two
vectors will always lie in a common plane
(place them tail to tail to see this), and so
we measure the angle in the plane that con-
tains both vectors. If the vectors are par-
allel, the plane is not unique, but the angle
is either 0 o or ±180 o , and it doesn't matter
which plane we choose.
The dot product provides a way for us
to compute the angle between two vectors.
Solving Equation (2.4) for θ,
Figure 2.26
The dot product is related to the
angle between two vectors.
a b
a b
Using the dot product to
compute the angle
between two vectors
θ = arccos
.
(2.5)
We can avoid the division in Equation (2.5) if we know that a and b are
unit vectors. In this very common case, the denominator of Equation (2.5)
is trivially 1, and we are left with
a b
(assume a and b are unit vectors).
Computing the angle
between two unit vectors
θ = arccos
If we do not need the exact value of θ, and need only a classification of
the relative orientation of a and b , then we need only the sign of the dot
product. This is the same idea illustrated in Figure 2.18, only now we can
relate it to the angle θ, as shown in Table 2.1.
a b
θ
Angle is
a and b are
0 o ≤ θ < 90 o
> 0
acute
pointing mostly in the same direction
θ = 90 o
0
right
perpendicular
90 o < θ ≤ 180 o
< 0
obtuse
pointing mostly in the opposite direction
Table 2.1. The sign of the dot product can be used as a rough classification of the angle
between two vectors.
Since the magnitude of the vectors does not affect the sign of the dot
product, Table 2.1 applies regardless of the lengths of a and b . However,
notice that if either a or b is the zero vector, then a b = 0. Thus, when
we use the dot product to classify the relationship between two vectors, the
dot product acts as if the zero vector is perpendicular to any other vector.
As it turns out, the cross product behaves differently.
 
Search WWH ::




Custom Search