What is a Quaternion Calculator?
A quaternion is a four-dimensional number written as \(q = w + xi + yj + zk\), where w is the scalar (real) part and (x, y, z) is the vector (imaginary) part. Quaternions are widely used in 3D computer graphics, robotics, aerospace and physics to represent rotations without the gimbal-lock problems of Euler angles. This calculator multiplies two quaternions, and also reports the norm of each input and the conjugate of the first.
How to Use It
Enter the four components (w, x, y, z) for each quaternion q1 and q2. The calculator returns the Hamilton product q1 × q2 as a new quaternion, the magnitude (norm) of both inputs, and the conjugate of q1. Quaternion multiplication is not commutative: in general q1 × q2 ≠ q2 × q1, so order matters.
The Formula Explained
The Hamilton product combines a scalar part and a vector part.
$$\begin{gathered} q_1 q_2 = (w_1 w_2 - x_1 x_2 - y_1 y_2 - z_1 z_2) + (w_1 x_2 + x_1 w_2 + y_1 z_2 - z_1 y_2)\,i \\ + (w_1 y_2 - x_1 z_2 + y_1 w_2 + z_1 x_2)\,j + (w_1 z_2 + x_1 y_2 - y_1 x_2 + z_1 w_2)\,k \\[1.5em] \text{where}\quad \left\{ \begin{aligned} q_1 &= \text{w}_1 + \text{x}_1\,i + \text{y}_1\,j + \text{z}_1\,k \\ q_2 &= \text{w}_2 + \text{x}_2\,i + \text{y}_2\,j + \text{z}_2\,k \end{aligned} \right. \end{gathered}$$The scalar result is w₁w₂ minus the dot product of the vector parts. The vector result is w₁v₂ + w₂v₁ plus the cross product v₁ × v₂. The norm is the Euclidean length \(\sqrt{w^2+x^2+y^2+z^2}\), and the conjugate simply negates the vector components: \(q^{*} = (w, -x, -y, -z)\).
$$\lVert q_1 \rVert = \sqrt{\text{w}_1^{2} + \text{x}_1^{2} + \text{y}_1^{2} + \text{z}_1^{2}}$$$$\lVert q_2 \rVert = \sqrt{\text{w}_2^{2} + \text{x}_2^{2} + \text{y}_2^{2} + \text{z}_2^{2}}$$$$q_1^{*} = \text{w}_1 - \text{x}_1\,i - \text{y}_1\,j - \text{z}_1\,k$$
Worked Example
Let q1 = (1, 2, 3, 4) and q2 = (5, 6, 7, 8). The scalar part is \(1\cdot5 - 2\cdot6 - 3\cdot7 - 4\cdot8 = 5 - 12 - 21 - 32 = -60\). The i part is \(1\cdot6 + 2\cdot5 + 3\cdot8 - 4\cdot7 = 6 + 10 + 24 - 28 = 12\). The j part is \(1\cdot7 - 2\cdot8 + 3\cdot5 + 4\cdot6 = 7 - 16 + 15 + 24 = 30\). The k part is \(1\cdot8 + 2\cdot7 - 3\cdot6 + 4\cdot5 = 8 + 14 - 18 + 20 = 24\). So q1 × q2 = (−60, 12, 30, 24).
FAQ
Is quaternion multiplication commutative? No. Because of the cross-product term, q1 × q2 generally differs from q2 × q1.
What is a unit quaternion? A quaternion with norm equal to 1. Unit quaternions represent pure rotations in 3D space.
How do I rotate a vector? Treat the vector as a quaternion with w = 0 and compute \(q \cdot v \cdot q^{*}\), where q is a unit quaternion encoding the rotation.