Quaternion Calculator
Quaternion arithmetic and axis-angle conversions.
Overview
The Quaternion Calculator performs the operations you need when working with 3D rotations: addition, multiplication, conjugate, norm, inverse and conversions between quaternion and axis-angle form. Quaternions sidestep gimbal lock and interpolate rotations smoothly, which is why they dominate 3D graphics and robotics.
It is built for game developers writing camera code, robotics students learning attitude representation and physicists working through rigid-body dynamics. The maths is awkward by hand; a calculator removes the bookkeeping.
How it works
A quaternion is q = w + xi + yj + zk with i² = j² = k² = ijk = -1. Multiplication uses the Hamilton product, which is associative but not commutative. The conjugate is q* = w - xi - yj - zk, the squared norm is q * q* = w² + x² + y² + z² and the inverse for a non-zero quaternion is q⁻¹ = q* / |q|².
A unit quaternion (cos(θ/2), sin(θ/2) * axis) represents a rotation of angle θ about the unit axis. To rotate a 3D vector v, treat it as a pure quaternion (0, v) and compute q * v * q⁻¹.
Examples
(1, 0, 0, 0) * (0, 1, 0, 0) → (0, 1, 0, 0)
conjugate of (1, 2, 3, 4) → (1, -2, -3, -4)
axis-angle (axis (0,0,1), angle 90°)
→ quaternion ≈ (0.707, 0, 0, 0.707)
|(1, 2, 3, 4)|² = 30, inverse ≈ (1, -2, -3, -4) / 30
FAQ
Why use quaternions instead of Euler angles?
They avoid gimbal lock and interpolate smoothly. Sequence-dependent Euler angles can hit singular configurations where one axis aligns with another.
Is quaternion multiplication commutative?
No. q1 * q2 ≠ q2 * q1 in general. The order matters and represents the composition of rotations.
What's the difference between a unit quaternion and a non-unit one?
Unit quaternions represent rotations. Non-unit quaternions add a scale factor and aren't used for pure rotations in graphics.
How are quaternions related to rotation matrices?
A unit quaternion converts to a 3x3 rotation matrix via a fixed formula. Both representations are equivalent for rotation; quaternions are smaller and easier to interpolate.
What is slerp?
Spherical linear interpolation — a way to smoothly blend two unit quaternions. The calculator focuses on arithmetic; slerp is a separate animation tool.