ISEGORIA / MATH ENCYCLOPEDIA
Quaternions: rotation as multiplication
Hamilton’s four-dimensional numbers: why a rotation is a sandwich with half the angle in each slice, how to interpolate between orientations, and why Euler angles jam where quaternions do not.
Before you begin: Vectors, the dot and cross products, rotation matrices and complex numbers
Predict, manipulate, then check your reasoning against the example and question. Graphs illustrate the mathematics; they do not replace a proof.
1. A rotation is a sandwich
A quaternion is a number \(q = w + x\mathbf i + y\mathbf j + z\mathbf k\) with \(\mathbf i^2 = \mathbf j^2 = \mathbf k^2 = \mathbf{ijk} = -1\). Write a 3D vector \(v\) as the pure quaternion \(x\mathbf i + y\mathbf j + z\mathbf k\); for two pure quaternions, \(uv = -u\cdot v + u\times v\). For a unit axis \(\mathbf n\) and an angle \(\theta\), the unit quaternion \(q = \cos\tfrac{\theta}{2} + \sin\tfrac{\theta}{2}\,\mathbf n\) rotates \(v\) by \(\theta\) about \(\mathbf n\) through the product \(q\,v\,q^{*}\). Drag the tips of \(v\) and \(\mathbf n\). The two small panels split \(v\) into its part along \(\mathbf n\) and its part across \(\mathbf n\), and show what each factor of the sandwich does to each part.
Worked example. Rotate \(v=\mathbf i\) by 90° about \(\mathbf k\): \(q=\tfrac{1}{\sqrt2}(1+\mathbf k)\), so \(q\,\mathbf i=\tfrac1{\sqrt2}(\mathbf i+\mathbf j)\), already a pure vector turned by 45°. Then \(\tfrac1{\sqrt2}(\mathbf i+\mathbf j)\cdot\tfrac1{\sqrt2}(1-\mathbf k)=\tfrac12(\mathbf i+\mathbf j+\mathbf j-\mathbf i)=\mathbf j\), turned by the other 45°.
Watch out. Order matters: \(q_2q_1\) means apply \(q_1\) first, exactly as for matrices, because \(q_2(q_1vq_1^*)q_2^*=(q_2q_1)v(q_2q_1)^*\). And q and −q give the same rotation, since the two signs cancel in the sandwich.
Why can one-sided multiplication v ↦ q v not be a rotation of 3D space?
Because it does not keep v pure: the part of v along n acquires the real part \(-\sin\tfrac\theta2\,(\mathbf n\cdot v)\). Left multiplication is a rotation of four-dimensional space. Only the combination with \(q^*\) on the right cancels the real part and leaves a rotation of the 3D vectors.
2. Travelling between orientations
Unit quaternions fill the 3-sphere in four dimensions, and every orientation appears there twice, as q and −q. The shortest way from one orientation to another is an arc of a great circle on that sphere, traversed at constant speed: slerp. Averaging the components and rescaling (nlerp) follows the same arc at uneven speed; averaging Euler angles takes a different, longer route. Watch the tick marks, placed at equal steps of t.
Worked example. For a 150° turn: \(\varphi=75°\), and slerp turns at 150° per unit t throughout. nlerp is fastest at \(t=\tfrac12\), where its speed is \(2\tan(\varphi/2)/\varphi\approx1.17\) times the average: about 176° per unit t.
Watch out. Before interpolating, flip the sign of \(q_B\) if \(q_A\cdot q_B<0\). Otherwise the path goes the long way round, through 360° − Ω, even though \(q_B\) and \(-q_B\) are the same orientation. The Euler path interpolates the z-y-x angles of A and B directly; any angle that crosses ±180° then runs the long way round.
Why is the nlerp path the same arc as slerp, only at a different speed?
The chord from \(q_A\) to \(q_B\) lies in the plane through the origin spanned by them. Rescaling each chord point onto the unit sphere keeps it in that plane, so it lands on the great circle between them. Equal steps along the chord project to unequal steps along the arc, bunched near the ends.
3. Gimbal lock
Euler angles describe an orientation as three turns in sequence: yaw ψ about z, pitch θ about the carried y axis, roll φ about the body’s own x axis. That is a set of three nested gimbals. When the pitch reaches ±90°, the roll axis swings onto the yaw axis and the three rings lose a dimension between them. The quaternion of the same orientation passes through that point without noticing.
Worked example. At \(\theta=90°\), \(R_y(90°)\) carries \(\hat x\) to \(-\hat z\), so \(R_z(\psi)R_y(90°)R_x(\varphi)=R_z(\psi-\varphi)R_y(90°)\). The orientations \((\psi,\varphi)=(50°,20°)\) and \((80°,50°)\) are identical: only \(\psi-\varphi\) is recorded.
Watch out. Gimbal lock is a flaw of the coordinates, not of the rotation: nothing physical happens to an aircraft at 90° pitch. It is unavoidable for any three-angle chart, because no three coordinates can cover all rotations without a singularity. Unit quaternions escape by using four numbers with one constraint.
Near θ = 90°, what Euler rates would it take to turn the aircraft about the missing axis?
Rates of order \(1/\sigma_{\min}=1/\sqrt{1-|\sin\theta|}\) per unit angular velocity, growing without bound as θ approaches 90°. A controller or integrator working in Euler angles sees yaw and roll rates explode although the motion itself is gentle.