Game Development Reference
In-Depth Information
If the vectors and are unit vectors, the division can be omitted because the
lengths of both vectors will just be one. This is demonstrated in Figure 3.6(a) . The
simplification of this equation is one of the reasons why you should normalize
vectors in advance if you only care about their direction.
Figure 3.6 Angle between unit vectors (a), and scalar projection (b).
Because the dot product can be used to calculate an angle between two vectors,
a couple of special cases are important to remember. If the dot product between
two unit vectors results in 0, it means they are perpendicular to each other because
cos(90°) = 0. If the dot product results in 1, it means the vectors are parallel and
facing in the same direction, and -1 means they are parallel and face in the oppos-
ite direction.
Another important aspect of the dot product is what's known as the scalar projec-
tion , which is illustrated in Figure 3.6(b) . In this application, you have both a unit
vector and a non-unit vector. The unit vector is extended such that a right triangle
Search WWH ::




Custom Search