Game Development Reference
In-Depth Information
schemes, and some of them are more useful than others. All are characterized by
very arbitrary mathematics, horrendous boundary conditions, and a tendency to find
difficult situations to crash on long after you think they've been debugged.
Gimbal lock was so significant that it featured in NASA's Apollo moon program.
The mathematics we'll end up with for orientations was not available, and Euler an-
gles were used in the flight-monitoring computers. To prevent the computers from
reaching gimbal lock and finding it impossible to represent the orientation of the
spacecraft, restrictions were placed on the way astronauts could exert control. If the
craft got too near gimbal lock, a warning would sound. There was no physical reason
why the craft couldn't orient in that way; it was purely a precaution to avoid having
NASA's computers fall over. Personally I take this as a salutary lesson. If the best minds
of NASA can't write software to cope with gimbal lock, I am certainly not going to try.
Fortunately there are much better ways of representing orientation. They may not
be as intuitive to visualize, but their mathematics is a lot more reliable.
Any rotation, or combination of rotations, in three dimensions can be represented as
a single rotation about a fixed axis. In other words, no matter what combination of
rotations takes place, we can always specify the orientation of an object as an axis and
an angle.
Although this isn't immediately obvious, you can easily verify it for yourself with
a small ball. Regardless of how you orient the ball, you can get it into any other ori-
entation by one rotation about a single axis.
We could use this as a representation for orientation (called, not surprisingly, an
“axis-angle representation”). It is roughly equivalent to the angle representation we
used for two dimensions, and suffers some of the same problems: we need to perform
lots of bounds-checking to make sure that the angle is always in the correct range
π,π ].
Having a vector (for the axis) and an angle gives us four degrees of freedom. The
rotation is only three degrees of freedom. The extra degree of freedom is removed
by requiring that the vector representing the axis is normalized. It represents only a
Another possible representation using axis and angle is the scaled axis representa-
tion. If the axis is normalized, then we can combine the axis and angle into one vector.
The direction of the vector gives the axis, and the magnitude of the vector gives the
angle. The angle is therefore in the range [0 ,π) . We don't need to represent negative
angles because they are equivalent to a positive rotation in the opposite direction.
The scaled axis representation is the most compact representation we have. It has
three values for three degrees of freedom, and it can represent any orientation. Al-
though it will be useful to us later in this chapter when we come to look at angular
velocity, it is almost never used to represent orientations.
This is for the same reasons we avoided a single angle representation for two-
dimensional rotations. The mathematics involved in manipulating a scaled axis rep-
Search Nedrilad ::

Custom Search