Game Development Reference
In-Depth Information
It can be somewhat daunting to remember these different rotation matrices. One
trick that helps is to assign a number to each coordinate axis: x = 1, y = 2, and
z = 3. This is because for the rotation about the x-axis, the element at (1,1) is 1,
whereas everything else in the first row/ column is 0. Similarly, the y and z rota-
tions have these values in the second and third row/column, respectively. The last
row/column is always the same for all three matrices. Once you remember the loc-
ation of the ones and zeros, the only thing left is to memorize the order of sine and
cosine.
Rotation matrices are orthonormal, which means that the inverse of a rotation mat-
rix is the transpose of that matrix.
Applying Multiple Transforms
Itisoftennecessarytocombinemultipletransformationsinordertogetthedesired
world transform matrix. For example, if we want to position a character at a spe-
cific coordinate and have that character scale up by a factor of two, we need both
a scale matrix and a translation matrix.
To combine the matrices, you simply multiply them together. The order in which
you multiply them is extremely important, because matrix multiplication is not
commutative. Generally, for the row-major representation, you want the world
transform to be constructed as follows:
WorldTransform = Scale×Rotation×Translation
The rotation should be applied first because rotation matrices are about the origin.
If you rotate first and then translate, the object will rotate about itself. However, if
thetranslation isperformedfirst,theobjectdoesnotrotateaboutitsownoriginbut
instead about the world's origin, as in Figure 4.3 . This may be the desired behavi-
or in some specific cases, but typically this is not the case for the world transform
matrix.
Search WWH ::




Custom Search