Quaternion Calculator
Work with quaternions for 3D rotations and algebra: add, subtract, multiply, normalize, invert, build rotation quaternions from axis–angle, and rotate 3D vectors with an interactive 3D visualization. Ideal for graphics, robotics and game development.
Full original guide (expanded)
Quaternion Calculator
3D rotations & algebraWork with quaternions for 3D rotations and algebraic operations. Define quaternions, add/subtract, multiply, conjugate, normalize, invert, build rotation quaternions from axis–angle and rotate 3D vectors with an interactive 3D visualization of the original and rotated vector.
Quaternion inputs & algebra
3D rotation with quaternion & interactive visualisation
Unit quaternion required for pure rotationRotated vector & rotation matrix
Simple orthographic-like projection. Rotate around different axes to see the path from v to v′.
Rotation matrix R (3×3) equivalent to qrot
For a unit quaternion q = (w, x, y, z), the matrix R is orthogonal with determinant 1, so it preserves lengths and angles.
What is a quaternion?
A quaternion is a hyper-complex number of the form \[ q = w + x \mathbf{i} + y \mathbf{j} + z \mathbf{k}, \] where \(w, x, y, z \in \mathbb{R}\) and \(\mathbf{i}, \mathbf{j}, \mathbf{k}\) satisfy \(\mathbf{i}^2 = \mathbf{j}^2 = \mathbf{k}^2 = \mathbf{ijk} = -1\). Quaternions extend complex numbers and form a non-commutative division algebra.
Basic quaternion operations
- Addition: component-wise — \(q_1 + q_2 = (w_1 + w_2,\; x_1 + x_2,\; y_1 + y_2,\; z_1 + z_2)\).
- Conjugate: \(\overline{q} = (w,\; -x,\; -y,\; -z)\).
- Norm: \(\|q\| = \sqrt{w^2 + x^2 + y^2 + z^2}\).
- Inverse: for \(q \neq 0\), \(q^{-1} = \overline{q} / \|q\|^2\).
Multiplication is more involved but encodes rotation when \(\|q\| = 1\).
Quaternions and 3D rotations
A unit quaternion (\(\|q\| = 1\)) can represent a 3D rotation. Given an axis–angle pair (a unit axis \( \mathbf{u} = (u_x,u_y,u_z)\) and angle \(\theta\)):
\[ q = \left(\cos\frac{\theta}{2},\; u_x \sin\frac{\theta}{2},\; u_y \sin\frac{\theta}{2},\; u_z \sin\frac{\theta}{2}\right). \]
To rotate a vector \(\mathbf{v} = (v_x,v_y,v_z)\), embed it as a pure quaternion \(p = (0, v_x, v_y, v_z)\) and compute:
\[ p' = q \, p \, q^{-1}. \] The rotated vector is the imaginary part of \(p'\).
Rotation matrix from quaternion
For a unit quaternion \(q = (w,x,y,z)\), the corresponding \(3\times3\) rotation matrix is
\[ R = \begin{bmatrix} 1 - 2(y^2 + z^2) & 2(xy - wz) & 2(xz + wy) \\ 2(xy + wz) & 1 - 2(x^2 + z^2) & 2(yz - wx) \\ 2(xz - wy) & 2(yz + wx) & 1 - 2(x^2 + y^2) \end{bmatrix}. \]
The calculator uses this matrix internally to show the linear map \( \mathbf{v}' = R\mathbf{v} \) alongside the direct quaternion formula.
Typical applications
- Game development & graphics: camera orientation, character bones, camera rigs.
- Robotics & drones: attitude representation, sensor fusion, control loops.
- Simulation & physics: rigid body orientation and numerical integration of angular velocity.
- Interpolation: smooth orientation interpolation using slerp between two unit quaternions.
Related algebra & 3D math tools
Formula (LaTeX) + variables + units
q = w + x \mathbf{i} + y \mathbf{j} + z \mathbf{k},
q = \left(\cos\frac{\theta}{2},\; u_x \sin\frac{\theta}{2},\; u_y \sin\frac{\theta}{2},\; u_z \sin\frac{\theta}{2}\right).
p' = q \, p \, q^{-1}.
R = \begin{bmatrix} 1 - 2(y^2 + z^2) & 2(xy - wz) & 2(xz + wy) \\ 2(xy + wz) & 1 - 2(x^2 + z^2) & 2(yz - wx) \\ 2(xz - wy) & 2(yz + wx) & 1 - 2(x^2 + y^2) \end{bmatrix}.
','\
Basic quaternion operations Addition: component-wise — \(q_1 + q_2 = (w_1 + w_2,\; x_1 + x_2,\; y_1 + y_2,\; z_1 + z_2)\). Conjugate: \(\overline{q} = (w,\; -x,\; -y,\; -z)\). Norm: \(\|q\| = \sqrt{w^2 + x^2 + y^2 + z^2}\). Inverse: for \(q \neq 0\), \(q^{-1} = \overline{q} / \|q\|^2\). Multiplication is more involved but encodes rotation when \(\|q\| = 1\).
- No variables provided in audit spec.
- Complex Number Calculator — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/complex-number - Boolean Algebra Calculator — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/boolean-algebra - Covariance Matrix — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/covariance-matrix - QR Decomposition — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/qr-decomposition - Fast Fourier Transform (FFT) — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/fft - Geometric Sequence — calcdomain.com · Accessed 2026-01-19
https://calcdomain.com/geometric-sequence
Last code update: 2026-01-19
- Initial audit spec draft generated from HTML extraction (review required).
- Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
- Confirm sources are authoritative and relevant to the calculator methodology.