Working with unit quaternions
As discussed, quaternions remove the limitations involved in compounding Euler-angle rotations. In this section, we will concentrate on reprogramming the camera in our project to pitch and roll with quaternions.
Before quaternions are multiplied, we must ensure they are unit quaternions. That means they will have a length of 1. If we go back to thinking of quaternion spacing being a sphere encompassing Euclidean space, then a quaternion represents a vector from the origin of both spaces to the surface of the sphere. In Figure 16.9, the vectors q1 and q2 represent these. The vector representing a quaternion is four-dimensional, with the coordinates storing the angle and axis as .
Of course, you must remember we can’t see these four dimensions in our 2D/3D sphere diagram, but they are there. In Figure 16.8, q3 represents an invalid quaternion in that it extends beyond the surface of the sphere. However, the rotation that it is meant to represent...