Quaternions
What Are Quaternions?
Quaternions are a number system that extends complex numbers to four dimensions, consisting of one real part and three imaginary parts commonly written as q = w + xi + yj + zk, where i, j, and k satisfy the relations i² = j² = k² = ijk = -1. Introduced by Irish mathematician William Rowan Hamilton in 1843 while working to extend two-dimensional complex number algebra to three-dimensional space, quaternions were initially controversial because their multiplication is non-commutative: the product AB differs from BA. Their significance in engineering and computation was recognized much later, when it became clear that unit quaternions provide a singularity-free, compact representation of three-dimensional rotations that avoids the gimbal lock problem inherent in Euler angle sequences. Quaternions now appear throughout robotics, aerospace, computer graphics, and signal processing.
The four-dimensional space of quaternions contains two geometrically distinct subsets of practical importance. The pure quaternions, with w = 0, can represent vectors in three-dimensional space. The unit quaternions, with magnitude equal to one, form a group under multiplication that is isomorphic to SU(2) and double-covers the rotation group SO(3), meaning that both q and -q represent the same physical rotation. This double-cover property is important for smooth interpolation but must be handled carefully in numerical implementations to avoid discontinuous sign flips.
Algebraic Structure
The quaternion algebra is an associative division algebra, meaning every nonzero element has a multiplicative inverse. Multiplication is defined by the Hamilton product, which distributes over addition and respects the defining relations among i, j, and k. The conjugate of a quaternion q = w + xi + yj + zk is q* = w - xi - yj - zk, and the norm is the real number |q| = sqrt(w² + x² + y² + z²). For a unit quaternion, the inverse equals the conjugate. The algebra and geometry of Hamilton's quaternions covers the foundational properties, including the relationship between quaternion multiplication and the cross and dot products of classical vector analysis.
Rotation Representation
A rotation of angle θ about unit axis vector n = (nx, ny, nz) is encoded as the unit quaternion q = cos(θ/2) + sin(θ/2)(nx·i + ny·j + nz·k). Applying this rotation to a vector v is performed via the sandwich product qvq*, where v is treated as a pure quaternion. This formula is computationally efficient: it requires fewer multiplications than a full 3×3 rotation matrix and avoids the trigonometric redundancy of Euler angles. It is also numerically stable under repeated composition, since small floating-point errors can be corrected by renormalizing the quaternion to unit length. The quaternions and rotations notes from Stanford's graphics curriculum provide a thorough derivation of this relationship and the conditions under which quaternion rotation and matrix rotation are equivalent.
Interpolation and Animation
One of the most widely used operations on unit quaternions is spherical linear interpolation (SLERP), which smoothly interpolates between two orientations along the shortest arc on the unit sphere in four-dimensional space. SLERP produces constant angular velocity transitions that feel natural for camera movements, robotic joint trajectories, and aircraft attitude animation. Standard linear interpolation of Euler angles or rotation matrices does not preserve unit length or produce constant-speed paths, making SLERP the standard choice in animation pipelines. The ACM paper on visualizing quaternion rotation in computer graphics examines how SLERP relates to the geometry of the four-dimensional sphere and discusses double-cover handling for minimal-path interpolation.
Applications
Quaternions have applications across many technical disciplines, including:
- Attitude representation and control in spacecraft and UAVs
- Camera and joint animation in video games and film visual effects
- Inertial navigation and sensor fusion in robotics
- Machine vision and pose estimation algorithms
- Quantum mechanics formalism, where SU(2) spinors represent spin-1/2 particles