Game Development Reference
In-Depth Information
Figure 3.5 Scalar multiplication.
Dot Product
Vectors do not have a single traditional multiplication operator. Instead, they have
two different products: the dot product and the cross product . The dot product
results in a scalar, whereas the cross product results in a vector. One of the most
common uses of the dot product in games is to find the angle between two vectors.
The dot product calculation is as follows:
But notice how that equation does not have an angle term anywhere in it. In order
to find the angle between two vectors, you must use the trigonometric formulation
of the dot product:
This formulation is based on the Law of Cosines, and a full derivation of it can be
found in the Lengyel topic in this chapter's references. Once we have this formu-
lation, we can then solve for θ :
Search WWH ::




Custom Search