On this page
When a game camera swings around a character, software has to store a 3D rotation and combine rotations quickly. Three angles (pitch, yaw, roll) break down at certain positions; four numbers, a quaternion, do not. Here is the idea, from the multiplication rules to one rotation you can check by hand.
What is a quaternion?
A quaternion is a number q = w + x i + y j + z k, with real w, x, y, z and three different square roots of −1 called i, j, k: a real part w plus a vector part (x, y, z). Multiplying a complex number by i turns it 90° on the Argand diagram (see how to prepare complex numbers and quadratic equations for JEE Main); quaternions carry that idea into 3D.
The rules came to William Rowan Hamilton on 16 October 1843, while he walked along the Royal Canal in Dublin, and he carved them into Brougham (now Broom) Bridge, as the history of quaternions on Wikipedia records.
Why is quaternion multiplication not commutative?
From ijk = −1 you can derive the products of pairs. Multiply both sides on the right by k: ijk·k = −k, so ij·(−1) = −k, which gives ij = k. Working the same way gives the full cycle:
ij = k, jk = i, ki = j
ji = −k, kj = −i, ik = −j
So ij and ji differ by a sign. This is not a defect: 3D rotations do not commute either. Turn a book 90° about a vertical axis, then 90° about a left-right axis; reset and do the turns in the other order, and the spine ends up pointing somewhere different. Memory aid: i → j → k → i gives a plus sign, backwards a minus, like the cross product (see how to prepare vectors and 3D geometry for JEE Main).
How do you rotate a vector with q v q⁻¹?
To rotate a vector v = (vx, vy, vz) by angle θ about a unit axis (ax, ay, az), the Wikipedia article on quaternions and spatial rotation gives this recipe:
Write the vector as a pure quaternion: v = vx i + vy j + vz k.
Build the unit quaternion q = cos(θ/2) + sin(θ/2)(ax i + ay j + az k).
For a unit quaternion, the inverse is just the conjugate: q⁻¹ = cos(θ/2) − sin(θ/2)(ax i + ay j + az k).
Compute q v q⁻¹. Its i, j, k parts are the rotated vector.
Notice the half angle: q appears on both sides, so each copy carries θ/2.
How does a 90° rotation about the z-axis work out?
Rotate v = (1, 0, 0) by 90° about the z-axis. A quarter turn anticlockwise (seen from above) should take it to (0, 1, 0).
Vector: v = i.
Axis (0, 0, 1) and θ/2 = 45°, so q = cos 45° + k sin 45° = (1 + k)/√2.
Inverse: q⁻¹ = (1 − k)/√2.
First product: q v = (1 + k) i /√2 = (i + ki)/√2 = (i + j)/√2, using ki = j.
Second product: (i + j)(1 − k)/2 = (i + j − ik − jk)/2.
Substitute ik = −j and jk = i: (i + j + j − i)/2 = 2j/2 = j.
The answer is j, the vector (0, 1, 0). Compute q⁻¹ v q instead and you get −j, the quarter turn the other way: non-commutativity doing real work.
If a step like ik = −j trips you up, the Fermi Concept Library covers every concept in physics, chemistry, biology, mathematics and computing, each with its own lesson. For practice, the Fermi Problem Library has worked problems with a step-by-step solver that explains the reasoning rather than printing an answer.
Why do unit quaternions avoid gimbal lock?
Gimbal lock is the loss of one degree of freedom when two of three rotation axes line up, as the Wikipedia article on gimbal lock explains. Pitch an aircraft's nose straight up and yaw and roll turn about the same line, so one direction of turning is gone.
The fault lies in the description, not in rotation itself. Any three-angle description of 3D rotations degenerates at some points, according to the quaternions and spatial rotation article. Unit quaternions are four numbers on a sphere (w² + x² + y² + z² = 1) that has no special points: straight up is just another orientation.
What is slerp and why do animators use it?
Ken Shoemake's 1985 paper Animating rotation with quaternion curves argued that unit quaternions are the most suitable for animation, and the Wikipedia article on slerp credits him with popularising spherical linear interpolation in computer graphics. To blend orientation q₀ into q₁ as t runs from 0 to 1:
slerp(q₀, q₁; t) = [sin((1 − t)Ω) q₀ + sin(tΩ) q₁] / sin Ω, where cos Ω = q₀ · q₁.
This moves along a great circle of the unit sphere in four-dimensional space at a steady rate, so the camera turns at constant angular speed. Since q and −q give the same rotation, so if q₀ · q₁ is negative, flip the sign of q₁ first to take the shorter path.



