History of Math

Quaternions & Non-Commutative Rotation

Hamilton searched for a number system describing 3D rotations. He found quaternions, where multiplication is not commutative: the order of rotations matters.

7 minLevel 3/3The interactive stage stays ad-free.
Rotation angle70°i j+kj i−kFinal-point gap69.0°

i² = j² = k² = ijk = −1, so i j = k while j i = −k. Order changes the product.

Hamilton’s rulesi² = j² = k² = ijk = −1i j = k, j k = i, k i = jj i = −k, k j = −i, i k = −j
×ijk
i−1k−j
j−k−1i
kj−i−1

A rotation is encoded as a unit quaternion q = cos(θ/2) + sin(θ/2)(xi + yj + zk). Applying rotation qᵢ then qⱼ composes as qⱼ · qᵢ. Because quaternion multiplication is not commutative, swapping the order gives a different product and therefore a different orientation. That is why 3D engines must track rotation order and why quaternions avoid the gimbal-lock problems of Euler angles.

Both cubes receive two 90°-style rotations, but in opposite order. The left cube uses i then j, the right uses j then i. The tracked amber vertex ends in a different place whenever the angle is not a multiple of 180°, which is precisely the failure of commutativity i j ≠ j i.

What you are seeing

1

A quaternion has a real part and three imaginary parts: a + bi + cj + dk.

2

The units satisfy i² = j² = k² = ijk = −1, which forces i j = k but j i = −k.

3

Because multiplication is non-commutative, applying rotation i then j is generally not the same as j then i.

Why it matters

Quaternions are used in 3D graphics, robotics, and spacecraft attitude control because they represent rotations compactly without gimbal lock.

Complexity & details

Multiplying two quaternions costs O(1); applying a quaternion rotation to a vector also costs O(1).

Frequently asked questions

Why not use ordinary numbers for 3D rotations?+

No three-dimensional associative division algebra exists over the reals. Quaternions use four dimensions and avoid the limitations of complex numbers.

What is gimbal lock?+

A problem with Euler angles where two rotation axes align, losing a degree of freedom. Quaternions avoid this representation issue.