Game Development Reference
In-Depth Information
Notice that since the point is rotating about the z-axis, its z coordinate remains un‐
changed. To write this in the vector-matrix notation, v ' = R v , let v = [x y z] and let R
be the matrix:
Here v' will be the new, rotated vector, v ' = [x r y r z r ] .
Rotation about the x- and y-axes is similar to the z-axis; however, in those cases the x
and y coordinates remain constant during rotations about each axis, respectively. Look‐
ing at rotation about each axis separately will yield three rotation matrices similar to the
one we just showed you for rotation about the z-axis.
For rotation about the x-axis, the matrix is:
And for rotation about the y-axis, the matrix is:
These are the rotation matrices you typically see in computer graphics texts in the con‐
text of matrix transforms, such as translation, scaling, and rotation. You can combine
all three of these matrices into a single rotation matrix to represent combinations of
rotations about each coordinate axis, using matrix multiplication as mentioned earlier.
In rigid-body simulations, you can use a rotation matrix to represent the orientation of
a rigid body. Another way to think of it is the rotation matrix, when applied to the
unrotated rigid body aligned with the fixed global coordinate system, will rotate the
rigid body's coordinates so as to resemble the body's current orientation at any given
time. This leads to another important consideration when using rotation matrices to
keep track of orientation in rigid-body simulations: the fact that the rotation matrix will
be a function of time.
Once you set up your initial rotation matrix for the rigid body, you'll never directly
calculate it again from orientation angles; instead, the forces and moments applied to
the rigid body will change the body's angular velocity, likewise causing small changes