Skip to content
Math

Quaternion Calculator

Enter two quaternions in the form q = a + bi + cj + dk and choose an operation. The calculator works out the result instantly, showing the full Hamilton product formula or the rotation axis-angle conversion, step by step. Supported operations include addition, subtraction, multiplication (Hamilton product), division (left and right quotient), conjugate, inverse, norm (magnitude), and rotation-quaternion generation from an axis vector and angle.

Your details

The scalar (real) component of the first quaternion.
Coefficient of the i imaginary unit in q1.
Coefficient of the j imaginary unit in q1.
Coefficient of the k imaginary unit in q1.
The scalar (real) component of the second quaternion.
Coefficient of the i imaginary unit in q2.
Coefficient of the j imaginary unit in q2.
Coefficient of the k imaginary unit in q2.
X component of the rotation axis vector (does not need to be a unit vector).
Y component of the rotation axis vector.
Z component of the rotation axis vector.
The angle of rotation in degrees.
deg
Result
-60 + 12i + 30j + 24k

The full quaternion result of the selected operation.

Result real part (a)-60
Result i coefficient (b)12
Result j coefficient (c)30
Result k coefficient (d)24
Norm of result72.249567
Norm of q15.477226
Norm of q213.190906
Real (a)-60
i (b)12
j (c)30
k (d)24

Hamilton product of q1 and q2 computed.

  • Quaternion multiplication is NOT commutative: q1 * q2 generally differs from q2 * q1.
  • The norm of a product equals the product of the norms: ||q1*q2|| = ||q1|| * ||q2||.
  • The norm of the result is 72.249567.
  • Norm of the result: 72.249567.

Next stepUse the rotation mode to build a unit rotation quaternion, then conjugate it to reverse the rotation.

Formula

q=a+bi+cj+dk,q=a2+b2+c2+d2,q=abicjdk,q1=qq2q = a + b\mathbf{i} + c\mathbf{j} + d\mathbf{k}, \quad \|q\| = \sqrt{a^2+b^2+c^2+d^2}, \quad q^* = a - b\mathbf{i} - c\mathbf{j} - d\mathbf{k}, \quad q^{-1} = \frac{q^*}{\|q\|^2}

Worked example

q1 = 1 + 2i + 3j + 4k, q2 = 5 + 6i + 7j + 8k. Hamilton product real part: (1)(5)-(2)(6)-(3)(7)-(4)(8) = 5-12-21-32 = -60. The full product is -60 + 12i + 30j + 24k.

What are quaternions?

Quaternions are a number system that extends the complex numbers. Where a complex number has one real part and one imaginary part (a + bi), a quaternion has one real part and three imaginary parts: q = a + bi + cj + dk. The imaginary units satisfy i^2 = j^2 = k^2 = ijk = -1, a rule that makes multiplication non-commutative. Hamilton discovered quaternions in 1843 while seeking a three-dimensional analogue of complex numbers, inscribing the key relation on Brougham Bridge in Dublin. Today they are the standard way to represent 3-D rotations in computer graphics, robotics, aerospace, and game engines because they avoid gimbal lock and interpolate smoothly (via SLERP).

How quaternion multiplication (Hamilton product) works

Given q1 = a + bi + cj + dk and q2 = e + fi + gj + hk, their product q1 * q2 is computed by distributing every term and applying the multiplication table: i*i = j*j = k*k = -1, i*j = k, j*k = i, k*i = j, and the reverses j*i = -k, k*j = -i, i*k = -j. The result is: real = ae - bf - cg - dh, i = af + be + ch - dg, j = ag - bh + ce + df, k = ah + bg - cf + de. Because j*i differs from i*j, multiplication is not commutative, and the left and right quotients of two quaternions are generally different. Division requires the inverse: q1 * q2^(-1) for right division and q1^(-1) * q2 for left division.

Using quaternions to represent 3-D rotations

A rotation by angle theta around a unit vector (nx, ny, nz) is encoded as q = cos(theta/2) + sin(theta/2)*(nx*i + ny*j + nz*k). The result is always a unit quaternion (norm = 1). To rotate a 3-D point p, form the pure quaternion p = 0 + px*i + py*j + pz*k and compute q * p * q^(-1). Because q is a unit quaternion, q^(-1) = q* (the conjugate), which is cheap to compute. Composing two rotations is just a Hamilton product of their quaternions, and the result is again a unit quaternion, so no re-normalisation is needed. This makes quaternions far more efficient for compounding rotations than rotation matrices, which must be re-orthogonalised to prevent drift.

Norm, conjugate, and inverse

The norm (magnitude) of a quaternion ||q|| = sqrt(a^2 + b^2 + c^2 + d^2) is the Euclidean length of the four-vector. A unit quaternion has norm 1. The conjugate q* = a - bi - cj - dk mirrors the imaginary parts. The product q * q* = ||q||^2, a real number, which makes the inverse easy: q^(-1) = q* / ||q||^2. For a unit quaternion this simplifies to q^(-1) = q*, halving the computation. When you divide quaternions, always state whether you mean left division (q1^(-1) * q2) or right division (q1 * q2^(-1)), because in general they are not equal.

Quaternion multiplication rules (Hamilton product)

*ijk
i-1k-j
j-k-1i
kj-i-1

Row label * column label. Key identities: i^2 = j^2 = k^2 = ijk = -1.

Frequently asked questions

Why does quaternion multiplication order matter?

Quaternion multiplication is non-commutative: q1 * q2 is not the same as q2 * q1. This mirrors the fact that 3-D rotations do not commute: rotating 90 degrees around X then Y gives a different result than Y then X. Always apply the Hamilton product in the order that matches your intended sequence of rotations.

What is a unit quaternion and why does it matter?

A unit quaternion has norm equal to 1. Only unit quaternions represent pure rotations without scaling. When you build a rotation quaternion from an axis and angle using this calculator, the result is automatically a unit quaternion. If you multiply two unit quaternions, the product is also a unit quaternion, so you can chain rotations without needing to re-normalise after each step.

What is the difference between left division and right division?

Because multiplication is non-commutative, there are two ways to divide quaternion q1 by q2. Left division gives q1^(-1) * q2: it removes q1 from the left side of an equation. Right division gives q1 * q2^(-1): it removes q2 from the right side. In most rotation applications you will use right division, but both are provided here for completeness.

How do I convert a rotation quaternion back to Euler angles?

Given q = a + bi + cj + dk (unit quaternion), the roll-pitch-yaw Euler angles are: roll = atan2(2(ab + cd), 1 - 2(b^2 + c^2)), pitch = arcsin(2(ac - db)), yaw = atan2(2(ad + bc), 1 - 2(c^2 + d^2)). Keep in mind that Euler angles have convention ambiguities (XYZ, ZYX, intrinsic vs extrinsic) and suffer from gimbal lock, which quaternions avoid.

How do I rotate a 3-D vector using a quaternion?

Form a pure quaternion p = 0 + px*i + py*j + pz*k from your vector (px, py, pz). Compute q * p * q^(-1) using the Hamilton product twice. If q is already a unit quaternion, q^(-1) is just the conjugate, so the rotation costs two quaternion multiplications. The imaginary part (b, c, d) of the result is the rotated vector.

What is SLERP and how do quaternions enable it?

SLERP (Spherical Linear Interpolation) smoothly interpolates between two orientations. For two unit quaternions q1 and q2, SLERP(q1, q2, t) = q1 * (q1^(-1) * q2)^t. Because unit quaternions live on the surface of a 4-D unit sphere (S^3), SLERP traces the shortest great-circle arc between the two orientations at constant angular speed, producing smooth animations without the sudden flips that naive Euler-angle interpolation can cause.

Sources

Written by Dr. Rajiv Menon, PhD Applied Mathematician · Bengaluru, India

Applied mathematician bridging algebraic theory and computational tools for students, engineers, and everyday problem-solvers.

Search 3,500+ calculators

Loading search…