Mathematics
Representing Rotations with Quaternions
Quick fact
The quaternion formula was carved into a bridge in Dublin, Ireland, by its discoverer: 'i² = j² = k² = ijk = −1' – creating a mathematical breakthrough in 1843.
Why this is interesting
You've likely rotated objects in a video game or on your phone, but did you know that the elegant behind-the-scenes math uses four-dimensional numbers? Why do animators and engineers prefer these mysterious 'quaternions' over simpler seeming angles?
Read the full explanation
Understanding Representing Rotations with Quaternions
In 3D space, we often describe rotation using three angles (pitch, yaw, roll) – known as Euler angles. But this system is flawed: it can cause 'gimbal lock,' when two axes align and a degree of freedom is lost. Quaternions offer a clever alternative. Like complex numbers extend the number line to a plane (2D), quaternions extend it to 4D, with three imaginary dimensions (i, j, k). A quaternion is written as a + bi + cj + dk, combining a scalar part (a) and a vector part (bi + cj + dk). To represent a rotation, we use a unit quaternion, meaning its magnitude is 1, and it encodes both the axis and angle of rotation: q = cos(θ/2) + (ux·i + uy·j + uz·k)·sin(θ/2), where (ux, uy, uz) is a unit vector along the axis of rotation, and θ is the angle. This compact representation avoids gimbal lock and makes chaining rotations straightforward and numerically stable.
A deeper explanation
The power of quaternions lies in their algebra. When you multiply two unit quaternions, the product corresponds to combining their rotations – the result is another unit quaternion. Conversely, to apply a rotation to a point, express the point as a pure imaginary quaternion (0, x, y, z), and compute q p q⁻¹, where q⁻¹ is the quaternion inverse. This double multiplication ensures the vector's magnitude is preserved, keeping the point on its sphere. Why does this work? Because quaternion multiplication has the property that it rotates vectors in 3D space when used in this sandwich form. Compared to rotation matrices (which require 9 numbers and are prone to error after many multiplications), quaternions need only 4 numbers and are easier to normalize to maintain accuracy. They are also the standard in graphics engines (like Unity and Unreal) and in control systems for spacecraft and drones. Understanding quaternions thus reveals a deep connection between algebra and geometry: a four-dimensional number system that perfectly encapsulates three-dimensional orientation.