Rotations need a path, not just endpoints
Interpolating rotation matrices entry by entry can leave the set of rotations: even the midpoint of two valid matrices can collapse lengths. For example, the midpoint of the identity and the half turn is , which sends to the zero vector. Unit quaternions give another representation in which a path can remain on a unit sphere. We use active rotations of column vectors in a right-handed coordinate system, with the Hamilton product below; changing conventions changes signs or composition order.
Definition 9.1.1
(Quaternion, conjugate, norm and product)
A quaternion is a pair with real scalar part and vector part . Its conjugate is , and its squared norm is ; is a unit quaternion when . For the product is
A pure quaternion is one with zero scalar part. In , the dot product of and is the ordinary dot product of their four components, written .
This product is associative but generally not commutative. Direct expansion gives and . Hence a unit quaternion has inverse , and conjugation reverses products: .
Definition 9.1.2
(Rotation action of a unit quaternion)
Represent a three-dimensional vector by the pure quaternion . For a unit quaternion , the transformed vector is the vector part of .
Theorem 9.1.3
(Unit quaternions act as proper rotations)
Let be unit quaternions.
- is a linear map of that preserves norms and has determinant , so it is a proper rotation.
- : apply first.
- If with a unit vector, then
- if and only if . Every proper rotation of equals for exactly two unit quaternions, and .
Proof
(Norm preservation, composition, axis form and the sign ambiguity)
The scalar part of is zero: conjugation reverses product order, so the conjugate of is , and an element equal to minus its conjugate is pure. Norm multiplicativity gives , and the map is linear in , hence orthogonal with determinant or . It depends continuously on the unit quaternion ; the unit 3-sphere is connected and gives the identity, so the determinant is always . This proves part 1. Associativity gives , which is part 2.
For part 3 write with , . A vector with splits into two cases. The product , so commutes with and : the parallel component is fixed. For , the product rule gives , so and therefore . Since , this equals . Adding the two components and using gives the formula. The parallel component stays fixed and the perpendicular component turns through by the right-hand rule.
For part 4, and give the same map because the two minus signs cancel, using . Conversely, if then for every pure ; multiplying on the left by and on the right by gives . So commutes with every pure quaternion; comparing vector parts shows that its vector part is zero. A unit quaternion with zero vector part has scalar or , so . Finally, every proper three-dimensional rotation has an axis–angle description, and part 3 realizes it by the half-angle quaternion; the identity is represented by .
The half-angle is essential: inserting itself in the quaternion's sine and cosine would produce a rotation through . A quaternion's four-vector dot product is not itself the physical rotation angle either: after choosing signs so the dot product is nonnegative, the smallest physical relative rotation angle is twice the angle between representatives.
Interpolate on the unit sphere
Let be unit quaternions and . If , replace by ; this changes no endpoint rotation and makes the chosen dot product nonnegative. Set , so .
Definition 9.1.4
(Spherical linear interpolation (SLERP))
For , the spherical linear interpolation of the sign-selected unit quaternions is
Theorem 9.1.5
(SLERP is a unit-length, constant-rate short path)
With , and as above, , , for every , and the quaternion has scalar part and a vector part of length . Hence the physical relative rotation from to has angle , which increases at constant rate in .
Proof
(An orthonormal pair in four dimensions)
The formula gives and directly. Let . Then and , so and are orthonormal in , and . Substitute this into the definition. The coefficient of is
by the sine addition identity , and the coefficient of is . Therefore , with norm . Multiplying by gives . Since , the product has scalar part and norm one, so it is a pure unit quaternion. By the axis-angle part of the rotation theorem the relative rotation has half-angle , i.e. angle .
Proof X-ray
Where the hypotheses enter the SLERP argument
The one non-routine move is replacing the pair by an orthonormal pair , which turns the weights and into plain and . Three hypotheses are used. First, is needed to divide by and to define . Second, unit length of and is what makes . Third, does not affect the unit-length computation at all; it enters only in the last sentence, where it guarantees , so the relative angle is at most and is the smallest angle rather than a wrapped one. The argument closes because the path is a great-circle arc of the unit sphere in traversed at constant speed, and constant speed on that arc is constant angular speed of the physical rotation.
When , the selected representatives coincide: use the constant path rather than divide by zero. This also handles originally antipodal inputs after the sign choice. At , the endpoint rotations differ by ; both signs of are equally short and can lead to different halfway orientations. A consistent declared tie rule is needed, and the shortest path need not be unique.
Counterexample mode
Skipping the sign choice takes the long way round
The claim: SLERP between any unit quaternions representing the two endpoint rotations follows the shortest rotation path. Take and , which represents a quarter turn about the axis. Here , so without the sign flip. Then , so , and the midpoint is , a rotation about through . Applied to it gives , whereas the short path has midpoint . The unflipped path sweeps the wrong way round. The repair is the stated rule: if , replace by before computing .
In floating-point code, normalize valid nonzero inputs, clamp a dot product rounded just outside before applying arccos, and handle very small separately. Normalized linear interpolation is a useful near-zero approximation, but is not generally the same constant-angular-rate path. A zero quaternion has no rotation and cannot be normalized.
Quick check
(Why is the componentwise average of two distinct unit quaternions with not a unit quaternion, and what does normalizing it do to the angular rate?)
Compute its squared norm.
Solution · Answer
, so , which is less than whenever . Dividing by the norm repairs the length. At the normalized midpoint equals the SLERP midpoint, but for other the normalized interpolation moves at a non-constant angular rate. If the average is zero and cannot be normalized, so the sign choice has to come first.
Worked rotation
Worked example 9.1.6
(Midpoint of a quarter turn about the z axis)
Take and , so the second endpoint is a turn about the positive axis. The quaternion angle is . At ,
Using the rotation formula with on yields : a physical turn. Negating the given before interpolation would give the same endpoint orientation; the sign-selection rule restores the same selected representative here.
Concept lensAlgebraic
SLERP as a power of the relative rotation
The proof shows for a pure unit quaternion , and . Defining the power as the latter expression, SLERP is
It starts at and applies a fraction of the relative rotation. In the example, .
Worked example 9.1.7
(Composing two quarter turns)
Let be a quarter turn about and a quarter turn about . With , and we have and . The product has scalar part and vector part . So , a rotation with , i.e. , about the axis . As a check, fixes and then sends it to ; the axis-angle formula with , also gives . Reversing the order, , has vector part : a different rotation, so order matters.
Worked example 9.1.8
(An antipodal input pair (boundary case))
Let and . Both represent the identity rotation, but and the unflipped formula would use and divide by . The sign rule replaces by , so and the constant path is used: the object does not move, as it should.
Common mistakes
Common mistake
(Putting the full angle into the quaternion)
To rotate by about , writing is wrong. By the axis formula this is the half-turn about and sends to . The correct quaternion is .
Common mistake
(Reading the four-dimensional angle as the rotation angle)
For and the quaternion angle is , but the physical rotation between the two orientations is . The physical angle is always twice the angle between sign-aligned representatives.
Exercises
Quick check
(Show directly from conjugation why and act identically on every vector.)
Use .
Solution · Answer
Since , , so the two quaternions give the same vector for every .
Quick check
(For and , determine the relative physical endpoint angle. Why does the sign choice at zero dot product require a tie rule?)
Compute first.
Solution · Answer
Here , so and the physical relative angle is : a half turn about . Both and are at the same angle from , so neither is preferred by the rule . The midpoints are , which are quarter turns about in opposite directions. These are different orientations, so an implementation must declare which sign it takes.
Quick check
(Explain why a componentwise linear average of two unit quaternions need not itself be a unit quaternion, and why needs sign handling before normalization.)
Use the squared norm of the sum.
Solution · Answer
, which is only if ; otherwise the average has norm for . For the average is the zero quaternion, which cannot be normalized, although and are the same rotation. Replacing by first removes the problem.