DSTO–TN–064028
DSTO–TN–0640Appendix D Quaternions Used in Computing:slerpRotation theory is important when creating a smooth fly through of a scene in whichcertain way points have been specified along with camera orientations at those points. Acamera’s orientation can be specified by a rotation matrix or quaternion that generatesthat orientation by rotating the initial orientation. So the question arises as <strong>to</strong> how best<strong>to</strong> interpolate the matrices or quaternions, in order <strong>to</strong> generate rotations that act on theinitial orientation <strong>to</strong> give visually acceptable intermediate orientations.For example, if two way-point orientations specified by rotation matrices R 0 and R 1are specified, then we might suppose that linear combinations of these with appropriateweightings will suffice <strong>to</strong> rotate the initial orientation <strong>to</strong> create intermediate orientations.But such is not the case; the intermediate rotation matrices are not simply given by linearinterpolations between R 0 and R 1 . For example in the simpler case of rotations in thexy plane, if the rotation matrix for 30 ◦ is R z (30 ◦ ) using (3.4), and that for 40 ◦ is R z (40 ◦ ),then the matrix0.9 R z (30 ◦ ) + 0.1 R z (40 ◦ ) (D1)is not equal <strong>to</strong> R z (31 ◦ ); being not orthogonal, it’s not a rotation matrix at all. Evenwhen orthogonalised using (3.13), what results still does not equal R z (31 ◦ ). So a moresophisticated matrix interpolation is needed.Whatever results are applicable <strong>to</strong> matrices, quaternions seem <strong>to</strong> be easier <strong>to</strong> use;and certainly most of the research in<strong>to</strong> interpolating orientations seems <strong>to</strong> revolve aroundquaternions. This seems <strong>to</strong> be mostly due <strong>to</strong> the fact that because of its numericallyintensive nature, rotation research tends <strong>to</strong> be mainly the domain of computer animationprogrammers; but unfortunately once various quaternion routines had been worked outand coded, the code got copied, unders<strong>to</strong>od, and used extensively; and quaternions becamethe de fac<strong>to</strong> way <strong>to</strong> solve problems of this sort. Nonetheless, as we’ll show in this appendix,quaternions are very easily interpolated <strong>to</strong> give more acceptable interpolation results thanare traditionally obtained using matrices.The fact that quaternions have a unit length given by a simple sum of squares of theircomponents means they can be treated as vec<strong>to</strong>rs in Euclidean four dimensions, so areable <strong>to</strong> be visualised as points on the surface of a “sphere”, as shown in Figure D1. In thisfigure, the initial orientation is represented by the quaternion (1, 0, 0, 0), because this isthe identity quaternion that doesn’t rotate at all, shown by applying (3.17):(0, x ′ ) = (1, 0, 0, 0)(0, x)(1, 0, 0, 0) = (0, x). (D2)We wish <strong>to</strong> generate a whole series of quaternions, each of which multiplies the initialorientation <strong>to</strong> produce some intermediate one. We must pass through the way-pointquaternion (0.9, 0.1, 0.1, 0.4) and finish at the final quaternion (0.7, 0.6, 0.2, 0.3). The verysimplest way is <strong>to</strong> make a linear interpolation, in angle, between way points on the sphere’ssurface, and so is called spherical linear interpolation, or slerp. To see how slerp is used<strong>to</strong> interpolate between two quaternions, draw them as vec<strong>to</strong>rs q 1 and q 2 lying in a planein Figure D2. (Previously we used e.g. Q <strong>to</strong> denote a quaternion. Here we use bold facevec<strong>to</strong>r notation <strong>to</strong> reinforce our treatment of quaternions as vec<strong>to</strong>rs, since that’s what29