Game Development Reference
In-Depth Information
Figure 14.3
Dot products can
'
t find targets.
Remember that the dot product measures angles and not direction. As you can see
from the diagram, the dot product won ' t tell you which way to turn, only how
much to turn. You need a cross product.
Graphically, the cross product returns a vector that is orthogonal to the plane formed
by the two input vectors. The cross product vector should be normalized before you
use it. Planes have two sides, and the resulting normal vector can only point in one
direction. How does it know which way to point? It turns out that cross products are
sensitive to the order of their input vectors. In other words, A cross B is not equal to
B cross A. As you might expect, it is exactly negative. This is where the handedness
of the coordinate system comes back into play. The cross product is always calculated
with this formula:
cross.x = (A.y * B.z)
(B.y * A.z)
cross.y = (A.z * B.x)
(B.z * A.x)
cross.z = (A.x * B.y)
(B.x * A.y)
 
Search WWH ::




Custom Search