Game Development Reference
In-Depth Information
Virtually every computer graphics book that we've read contains a chapter or section
on using rotation matrices. Far fewer discuss quaternions, but if you're familiar with
quaternions, it's probably in the same context as rotation matrices—that is, how they
are used to rotate 3D points, objects, scenes, and points of view. In a simulation, however,
you need to get a little more out of rotation matrices or quaternions and will use them
in a different context than what you might be accustomed to. Specifically, you need to
keep track of a body's orientation in space and, moreover, the change in orientation over
time. So it's in this light that we'll discuss rotation matrices and quaternions. We'll try
to be as concise as possible so as not to cloud the water with the proofs and derivations
that you can find in the texts referred to in the Bibliography .
Rotation Matrices
A rotation matrix is a 3×3 matrix that, when multiplied with a point or vector, results
in the rotation of that point about some axis, yielding a new set of coordinates. You can
rotate points about axes in one coordinate system or you can use rotation matrices to
convert points from one coordinate system to another, where one is rotated relative to
the other.
Rotating a vector by a rotation matrix is typically written as follows: if v is a vector, and
R is a rotation matrix, then v ' is v rotated by R according to the formula:
v ' = R v
You can combine multiple rotation matrices reflecting multiple sequential rotations into
a single rotation matrix using usual matrix multiplication. If the rotation matrices are
expressed in terms of fixed, global coordinates, then they are combined as follows:
R c = R 1 R 2
Here R c is the combined rotation matrix reflecting a rotation first by R 1 and then by R 2 .
If the rotation matrices are expressed in terms of rotating, body-fixed coordinates, then
they are combined in the reverse order as follows:
R c = R 2 R 1
We won't go into the proof of this relation, but the reason it's different depending on
how you've defined your rotation matrices is that rotation matrices defined in fixed
coordinates are unaffected by the rotation itself since the coordinate axes stay fixed. On
the other hand, if the rotation matrices are defined relative to a coordinate system that
is rotating due to sequential application of rotation matrices, then all rotation matrices
after the first will be affected since they were first defined relative to the original state
of the coordinate system—that is, before the first rotation matrix was applied. This
means that the subsequent rotation matrices must be corrected to reflect the new system
Search Nedrilad ::




Custom Search