Quick Answer
This quaternion calculator multiplies, adds, subtracts, and divides quaternions written as q = a + bi + cj + dk, using the Hamilton product q₁q₂ = (ae − bf − cg − dh) + (af + be + ch − dg)i + (ag − bh + ce + df)j + (ah + bg − cf + de)k. It also returns the conjugate, norm, inverse, unit form, rotation axis–angle, and Euler angles of any quaternion.
Quaternion Formulas: Hamilton Product, Norm, Inverse and Slerp
A quaternion is written q = a + bi + cj + dk, where a is the scalar part and b, c, d are the vector part. Multiplication follows Hamilton’s rules i² = j² = k² = ijk = −1, which make the product non-commutative: q₁ × q₂ and q₂ × q₁ are different quaternions, and this calculator prints both so the difference is visible rather than assumed.
Hamilton product. For q₁ = (a, b, c, d) and q₂ = (e, f, g, h):
q₁ × q₂ = (ae − bf − cg − dh, af + be + ch − dg, ag − bh + ce + df, ah + bg − cf + de)
The remaining operations follow from that product. The conjugate q* negates the vector part. The norm is |q| = √(a² + b² + c² + d²) — the same sum-of-squares root a square root calculator evaluates, just over four terms. The inverse is q⁻¹ = q* / |q|², so division is defined as q₁ × q₂⁻¹ rather than as a separate operation.
A quaternion of norm 1 encodes a 3D rotation. Writing q̂ = (cos(θ/2), x·sin(θ/2), y·sin(θ/2), z·sin(θ/2)) turns an axis (x, y, z) and an angle θ into a unit quaternion, and reading that backwards recovers the axis and angle. Note the half-angle: a 90° rotation stores 45° inside the quaternion, which is why q and −q describe the identical rotation.
| Quantity | Formula | Result for q = 1 + 2i + 3j + 4k |
|---|---|---|
| Conjugate q* | a − bi − cj − dk | 1 − 2i − 3j − 4k |
| Norm |q| | √(a² + b² + c² + d²) | √30 ≈ 5.4772 |
| Inverse q⁻¹ | q* / |q|² | 0.0333 − 0.0667i − 0.1j − 0.1333k |
| Unit form q̂ | q / |q| | 0.1826 + 0.3651i + 0.5477j + 0.7303k |
| Rotation angle | 2·arccos(a) on the unit form | 158.96° |
Rotations compose by multiplication, and the order reads right to left: q₁ × q₂ applies q₂ first, then q₁. To rotate an actual vector v, write it as a pure quaternion (0, v) and evaluate the sandwich product q × (0, v) × q⁻¹. In this calculator that is two passes through Product mode, using Analyse to read off q⁻¹ in between — for a unit quaternion the inverse is just the conjugate, so the second factor is free.
For interpolation the calculator uses spherical linear interpolation. Given two unit quaternions separated by an angle Ω = arccos(q̂₁ · q̂₂), the point at parameter t is slerp = [sin((1−t)Ω)·q̂₁ + sin(tΩ)·q̂₂] / sin Ω. This traces the arc at a constant angular rate, which straight component-wise averaging does not.
Three representations describe the same 3D rotation, and each fails at something the others handle. Quaternions are compact and interpolate cleanly; rotation matrices apply to a vector in one multiply; Euler angles are the only one a person can read at a glance.
| Representation | Numbers stored | Gimbal lock | Interpolates smoothly |
|---|---|---|---|
| Quaternion | 4 | No | Yes, via slerp |
| Rotation matrix | 9 | No | No, needs re-orthogonalising |
| Euler angles | 3 | Yes, at pitch ±90° | No |
| Axis and angle | 4 | No | Only about a fixed axis |
The four-number quaternion also carries one redundancy: unit length. Repeated multiplication lets rounding error creep in, so long chains of rotations need periodic renormalising — the Unit form row in Analyse mode is what you would divide by.
How to Use the Quaternion Calculator
- Pick the operation.
Choose Product, Sum, Difference, Quotient, Slerp, or Analyse q. The inputs on the left change to match — Analyse hides the second quaternion, and Slerp adds the interpolation parameter.
- Type the four components.
Enter a, b, c, d for q₁ and, if the mode needs it, e, f, g, h for q₂. Whole numbers, decimals and fractions such as
1/2or-3/4all work. Results update as you type. - In Analyse mode, choose how you want to enter q.
The “Enter q as” dropdown accepts raw components, an axis plus an angle in degrees, or Euler roll / pitch / yaw in degrees. Whichever you pick, the readout shows all of them, so the tool converts in both directions.
- In Slerp mode, set t.
Use t = 0 for q₁, t = 1 for q₂, and anything between for a point on the arc. Values outside 0–1 still compute but extrapolate past the two orientations, and the calculator says so.
- Read the panel on the right.
Product mode adds a step-by-step breakdown of all four components. Analyse mode lists conjugate, norm, inverse, unit form, rotation axis, rotation angle, Euler angles and gimbal-lock state.
Euler convention. This calculator uses ZYX intrinsic angles — yaw about Z, then pitch about Y, then roll about X — the aerospace convention documented in Wikipedia’s conversion reference. Twelve valid Euler orders exist; the same quaternion produces different angle triples under each, so always check which order a library expects before copying numbers between tools.
Worked Examples: Product, Rotation, Slerp and Gimbal Lock
Non-commutative product. With q₁ = 1 + 2i + 3j + 4k and q₂ = 5 + 6i + 7j + 8k, the calculator returns q₁ × q₂ = −60 + 12i + 30j + 24k but q₂ × q₁ = −60 + 20i + 14j + 32k. The scalar part matches; all three vector components differ. Order matters for rotations too — rotating 90° about X then 90° about Y does not land where the reverse order lands.
Axis and angle from components. Enter roll 0, pitch 0, yaw 90 in Analyse mode and the tool builds 0.7071 + 0i + 0j + 0.7071k, reporting norm 1, rotation axis (0, 0, 1) and rotation angle 90°. Switching the dropdown to axis-and-angle and entering axis (0, 0, 1) with θ = 90 produces the identical quaternion — the two representations are the same rotation written differently.
Rotating a vector. Take the unit vector along x, v = (1, 0, 0), and turn it 90° about Z using q = 0.7071 + 0i + 0j + 0.7071k. Write the vector as the pure quaternion 0 + 1i + 0j + 0k and multiply: Product mode gives q × v = 0 + 0.7071i + 0.7071j + 0k. Multiply that by the conjugate 0.7071 + 0i + 0j − 0.7071k and the result is 0 + 0i + 1j + 0k — the vector (0, 1, 0). The x-axis has swung onto the y-axis, which is the right-hand rule for a positive turn about Z. The scalar part of the answer is 0, as it must be for a rotated vector; if it is not, one of the two multiplications was taken in the wrong order.
Slerp at the midpoint. Set q₁ to the identity 1 + 0i + 0j + 0k and q₂ to that same 90° turn about Z, then set t = 0.5. The result is 0.9239 + 0i + 0j + 0.3827k, which is exactly a 45° rotation about Z. The panel reports Ω = 45° between the quaternions and 90° between the rotations — the factor of two is the half-angle appearing again.
| t | Slerp result | Rotation about Z |
|---|---|---|
| 0 | 1 + 0i + 0j + 0k | 0° |
| 0.25 | 0.9808 + 0i + 0j + 0.1951k | 22.5° |
| 0.5 | 0.9239 + 0i + 0j + 0.3827k | 45° |
| 0.75 | 0.8315 + 0i + 0j + 0.5556k | 67.5° |
| 1 | 0.7071 + 0i + 0j + 0.7071k | 90° |
The rotation column advances in equal 22.5° steps. That constant rate is the property slerp exists to provide, and it is what separates it from averaging the components and renormalising.
The Arc taken row matters more than it looks. Negate q₂ — enter −0.7071 for both e and h — and the midpoint is unchanged, because q and −q are the same orientation, but the readout now reports that q₂ was negated. Skipping that step is the classic animation bug: the character takes the 270° route to a pose 90° away, spinning the long way for no visible reason.
Gimbal lock. Enter roll 20, pitch 90, yaw 30 in Euler mode. The tool returns 0° / 90° / 10° and flags the gimbal-lock row. Nothing was lost by mistake: at pitch = ±90° the roll and yaw axes align, so only one combination of them survives. Here that combination is yaw − roll = 30 − 20 = 10°, and the convention is to report roll as 0 and put the whole 10° into yaw. Feed those angles back in and you get the same quaternion. The axis and angle readout, by contrast, stays perfectly stable — which is the practical argument for storing rotations as quaternions in the first place.
Quaternions do not remove gimbal lock from Euler angles. They avoid it while the rotation is stored as a quaternion. The moment you convert to roll, pitch and yaw for display or for a file format, the singularity is back — the loss happens in the conversion, not in the storage. NASA’s Shuttle Program working relationships report sets out the same Euler, quaternion and transformation-matrix correspondences used here.
Quaternion Calculator: FAQ
Because quaternion multiplication is not commutative, and the two products are genuinely different numbers. Showing only one would let you assume an order that your own code may not use.
A unit quaternion stores the half-angle: the scalar part is cos(θ/2), not cos θ. So a scalar of 0.7071 is cos 45°, which represents a 90° rotation.
No — they are the same rotation, reached the short way and the long way round. Slerp mode uses this: if the two inputs have a negative dot product it silently negates q₂ so the interpolation takes the shorter arc, and the readout says it did.
Above a dot product of 0.9995 — about 1.81° apart — sin Ω is small enough that dividing by it loses precision, so it switches to a straight linear interpolation followed by renormalisation. The readout names which formula was used.
Quotient mode computes q₁ × q₂⁻¹. Because the product is non-commutative, this right-division differs from q₂⁻¹ × q₁, so state which one you mean when comparing against another tool. A quaternion of zero norm has no inverse and the calculator refuses the division.
That is gimbal lock approaching: as pitch nears ±90° the roll and yaw axes converge and their split becomes ill-conditioned, so tiny input changes swing both wildly. The calculator flags this from 89° onward, and the axis-and-angle readout remains stable throughout.
ZYX intrinsic — yaw about Z, then pitch about Y, then roll about X. If another library reports different angles for the same quaternion, an order mismatch is the first thing to check, since twelve valid orders exist.
Infinitely many — every unit quaternion with a zero scalar part squares to −1, so i, j, k and the whole unit sphere between them all qualify. Over the reals and complex numbers a quadratic formula calculator returns at most two roots, which is exactly the guarantee that non-commutative multiplication removes.
