To understand the benefits of using quaternions you have to consider different ways to represent rotations.
Here are few ways with a summary of the pros and cons:
- Euler angles
- Rotation matrices
- Axis angle
- Quaternions
- Rotors (normalized Spinors)
Euler angles are the best choice if you want a user to specify an orientation in a intuitive way. They are are also space efficient (three numbers). However, it is more difficult to linear interpolate values. Consider the case where you want to interpolate between 359 and 0 degrees. Linearly interpolating would cause a large rotation, even though the two orientations are almost the same. Writing shortest path interpolation, is easy for one axis, but non-trivial when considering the three Euler angles(for instance the shortest route between (240, 57, 145) and (35, -233, -270) is not immediately clear).
Rotation matrices specify a new frame of reference using three normalized and orthogonal vectors (Right, Up, Out, which when multiplied become the new x, y, z). Rotation matrices are useful for operations like strafing (side ways movement), which only requires translating along the Right vector of the camera's rotation matrix. However, there is no clear method of interpolating between them. The are also expensive to normalize which is necessary to prevent scaling from being introduced.
Axis angle, as the name suggests, are a way of specifying a rotation axis and angle to rotate around that axis. You can think of Euler angles, as three axis angle rotations, where the axises are the x, y, z axis respectively. Linearly interpolating the angle in a axis angle is pretty straight forward (if you remember to take the shortest path), however linearly interpolating between different axises is not.
Quaternions are a way of specifying a rotation through a axis and the cosine of half the angle. They main advantage is I can pick any two quaternions and smoothly interpolate between them.
Rotors are another way to perform rotations. Rotors are basically quaternions, but instead of thinking of them as 4D complex numbers, rotors are thought of as real 3D multivectors. This makes their visualization much more understandable (compared to quaternions), but requires fluency in geometric algebra to grasp their significance.
Okay with that as the background I can discuss a real world example.
Say you are writing a computer game
where the characters are animated in
3ds Max. You need to export a
animation of the character to play in
your game, but cannot faithfully
represent the interpolation used by
the animation program, and thus have
to sample. The animation is going to
be represented as a list of rotations
for each joint. How should we store
the rotations?
If I am going to sample every frame,
not interpolate, and space is not an
issue, I would probably store the
rotations as rotation matrices. If
space was issue, then Euler angles.
That would also let me do things like
only store one angle for joints like
the knee that have only one degree of
freedom.
If I only sampled every 4 frames, and
need to interpolate it depends on
whether I am sure the frame-rate will
hold. If I am positive that the
frame-rate will hold I can use axis
angle relative rotations to perform
the interpolation. This is atypical.
In most games the frame rate can drop
past my sampling interval, which would
require skipping an element in the
list to maintain the correct playback
speed. If I am unsure of what two
orientations I need to interpolate
between, then I would use quaternions
or rotors.