Quaternion Rotation Multiply Calculator | Compose 3D Rotations with the Hamilton Product
Multiply two quaternions (w, x, y, z) with the Hamilton product and see the composed quaternion, its norm |q|, and the rotation axis-angle on one screen. Built for anyone debugging 3D rotation math without hand-tracking sixteen signed terms.
💡 About this tool
If you've ever chained two rotations in a game engine or an IMU stack and gotten a result that looked subtly wrong, you know the pain. Quaternions dodge gimbal lock and interpolate cleanly, which is why Unity, Unreal, three.js, ROS, and flight controllers all lean on them. But composing rotations means multiplying quaternions, and that multiplication is unforgiving by hand.
The Hamilton product expands to sixteen products added and subtracted with specific signs. Flip one sign and the rotation silently breaks. Worse, the product is non-commutative: a × b and b × a are different rotations, so a swapped operand order is a classic bug that compiles fine and ships broken.
Drop in the eight components of A and B and this tool evaluates all four output components, starting from w = aw·bw − ax·bx − ay·by − az·bz. It also treats the result as a unit quaternion and recovers the rotation axis (x, y, z) and angle, so you can answer "what single rotation does this composition actually represent?" — handy for sanity-checking a transform or confirming your quaternion stayed normalized.
🧐 Frequently Asked Questions
Which order is correct, A × B or B × A?
It depends on your convention. Applying rotation A first and then B is often written q = b × a in libraries that pre-multiply column vectors. This tool computes q = a × b exactly as labeled, so swap A and B to match your engine's composition order.
Why isn't my norm exactly 1? At least one of your inputs isn't a unit quaternion. Only unit quaternions represent pure rotations. Divide each component by |q| to normalize before composing.
Why does the axis show (1, 0, 0)? When the angle is near 0° (the scalar part w is near 1), the axis is mathematically undefined. The tool falls back to the x-axis as a placeholder — the rotation is effectively identity.
What do scalar and vector parts mean?
A quaternion has one scalar part w and three vector parts x, y, z. For a rotation, w = cos(θ/2) and (x, y, z) = sin(θ/2) · axis.
Can it output Euler angles or a matrix? This tool focuses on the product and the axis-angle decomposition. Once you have the axis and angle, your engine's built-in helpers will convert to Euler angles or a rotation matrix.
📚 Why engines prefer quaternions over matrices
A common Stack Overflow question is "why not just multiply rotation matrices?" Matrices work, but they cost nine floats per rotation versus four, drift away from orthonormality faster under repeated multiplication, and can't be interpolated smoothly without extra work. Quaternions renormalize with a single division and support spherical linear interpolation (Slerp) for constant-speed blends between orientations.
That last property is why quaternions dominate animation rigs and camera systems: blending two keyframed poses is just a Slerp, not a tangle of matrix decompositions. The trade-off is that the multiplication is opaque to read at a glance — which is exactly the gap a calculator like this fills when you're staring at a rotation bug at 2 a.m.