Game Development Reference
In-Depth Information
vector being transformed are expressed relative to the basis (the easy situ-
ation on the left), or if the coordinates of the vector and the basis vectors
are all expressed in the same coordinate space (the hard situation on the
right).
Linear algebra provides a number of general-purpose tools for solving
systems of linear equations like this, but we don't need to delve into these
topics, because the solution to this system is not our primary aim. For
now, we're interested in understanding one special situation for which the
solution is easy. (In Section 6.2, we show how to use the matrix inverse to
solve the general case.)
The dot product is the key. Remember from Section 2.11.2 that the dot
product can be used to measure distance in a particular direction. As we
observed in that same section, when using the standard basis p = [1,0,0],
q = [0,1,0], and r = [0,0,1], corresponding to the object axes being parallel
with the world axes in our robot example, we can dot the vector with a
basis vector to “sift out” the corresponding coordinate.
b x = u p = u
1
0
0
= u x
b y = u q = u
0
1
0
= u y
b z = u r = u
0
0
1
= u z
Algebraically, this is rather obvious. But does this “sifting” action work for
any arbitrary basis? Sometimes, but not always. In fact, we can see that
it doesn't work for the example we have been using. Figure 3.13 compares
the correct coordinates a x and a y with the dot products a p and a q .
(The illustration is completely correct only if p and q are unit vectors.)
Notice that, in each case, the result pro-
duced by the dot product is larger than
the correct coordinate value. To understand
what's wrong, we need to go back and cor-
rect a little lie that we told in Chapter 1. We
said that a coordinate measures the displace-
ment from the origin in a given direction; this
displacement is exactly what the dot prod-
uct is measuring. While that is the simplest
way to explain coordinates, it works only un-
der special circumstances. (Our lie isn't that
harmful because these circumstances are very
common!) Now that we understand basis vec-
tors, we're ready for the more complete de-
scription.
Figure 3.13
The dot product doesn't “sift out”
the coordinate in this case.
 
Search WWH ::




Custom Search