Quaternion rotations
Drag to rotate a 3D shape, then watch Euler angles seize up at the poles while quaternions glide through. SLERP interpolation, gimbal lock, and the geometry of 4D rotation — all in one canvas.
q = w + xi + yj + zk |q| = 1 SLERP(q₀, q₁, t) = q₀(q₀¹q₁)ᵗ
The gimbal lock problem
Euler angles describe orientation as three sequential rotations — yaw, pitch, roll. This works until the pitch reaches ±90°, at which point the yaw and roll axes align and one degree of freedom is lost. The object appears to “seize up” at the poles. This is gimbal lock, and it’s a fundamental limitation of representing 3D rotations as three separate angle values.
Quaternions
A quaternion q = w + xi + yj + zk is a four-dimensional number. Unit quaternions (those with |q| = 1) live on the surface of a 4D hypersphere and can represent any 3D rotation without gimbal lock. To rotate a point p by quaternion q, compute q·p·q*, where q* is the conjugate. This is equivalent to a rotation matrix but composes more cleanly and interpolates more naturally.
SLERP
Spherical Linear Interpolation traces the shortest arc on the quaternion hypersphere between two orientations. Unlike interpolating Euler angles (which can take bizarre indirect paths), SLERP always produces the most natural rotation at constant angular velocity. This is why every 3D engine, from game engines to spacecraft controllers, uses quaternions internally.
The hypersphere
Unit quaternions form S³, the 3-sphere embedded in 4D space. Each point on this sphere corresponds to a unique 3D rotation — except that q and −q represent the same rotation (double cover of SO(3)). The quaternion display on the right panel shows the current rotation as coordinates on this hypersphere.
← Back to all experiments