Game Development Reference
In-Depth Information
angles internally, and those that don't still often represent orientations to the user as
Euler angles.
Unfortunately Euler angles are almost useless for our needs. We can see this
by looking at some of the implications of working with them. You can follow this
through by making a set of axes with your hand (as described in section 2.1.1), re-
membering that your imaginary object is facing in the same direction as your palm—
along the Z axis.
Imagine we first perform a pitch, by 30 or so. The object now has its nose up in
the air. Now perform a yaw by about the same amount. Notice that the yaw axis is no
longer pointing up: when we pitched the object, the yaw axis also moved. Remember
where the object is pointing. Now start again, but perform the yaw first, then the
pitch. The object will be in a slightly different position. What does this mean? If we
have a rotation vector like
0 . 3
0 . 4
0 . 1
in what order do we perform the rotations? The result may be different for each or-
der. What is more, because the order is crucial, we can't simply use regular vector
mathematics to combine rotations. In particular,
r 1 ·
r 2 =
r 2 ·
r 1
where r 1 and r 2 are two rotations.
In case you think that the problem is caused by moving the rotation axes around
(i.e., keeping them welded to the object rather than fixed in the world), try it the
other way. Not only does the same problem still occur, but now we have another
issue—gimbal lock.
Gimbal lock occurs when we rotate an object such that what started as one axis
now aligns with another. For example, assume we're applying the rotations in the
order X, then Y, then Z. If we yaw around by 90 (i.e., no X rotation, 90 Y rotation),
the front of the object is now pointing in the negative X direction. Say we wanted to
have the object roll slightly now (roll from its own point of view). We can't do that: the
axis we need (the local Z axis) is now pointing in the X direction, and we've already
passed the point of applying X rotations.
So maybe we should have applied a little bit of X rotation first before rotating in
the Y direction. Try it: you can't do it. For this particular problem we could perform
the rotations in a different order—ZYX, for example. This would solve the problem
for the previous example, but there'd be new orientations that this ordering couldn't
represent. Once rotations of around 90 come into play, we can't achieve all desired
orientations with a combination of Euler angles. This is called “gimbal lock.”
There are some ways to mitigate the problem, by using combinations of axes,
Alternatively we can repeat rotations around some axes. There are a lot of different
Search Nedrilad ::

Custom Search