Quaternion Calculator

Quaternion operations: add, multiply, conjugate, inverse, normalize, axis-angle conversion, rotation matrix, and 3D rotation representation.

q₁ = w + xi + yj + zk

q₂ = w + xi + yj + zk

Result w
0.499990
Scalar component of q₁ · q₂
Result x (i)
0.499990
i component of q₁ · q₂
Result y (j)
0.499990
j component of q₁ · q₂
Result z (k)
0.499990
k component of q₁ · q₂
Result Norm
0.999981
|result| = √(w²+x²+y²+z²) = 0.999981
|q₁|
0.999990
Norm of q₁

Component Magnitudes

w
0.5000
x (i)
0.5000
y (j)
0.5000
z (k)
0.5000

Components Table

Quaternionwx (i)y (j)z (k)Norm
q₁0.70710.70710.00000.00001.0000
q₁ · q₂0.50000.50000.50000.50001.0000

Rotation Matrix (from q₁)

Col 1Col 2Col 3
Row 11.00000.00000.0000
Row 20.0000-0.0000-1.0000
Row 30.00001.0000-0.0000

Quaternion Reference

RuleFormula
Basisi² = j² = k² = ijk = −1
MultiplicationNon-commutative: q₁q₂ ≠ q₂q₁ in general
Conjugateq* = w − xi − yj − zk
Inverseq⁻¹ = q* / |q|²
Rotationv' = q·v·q⁻¹ (v as pure quaternion)
Axis-Angleq = cos(θ/2) + sin(θ/2)·(uxi + uyj + uzk)
Planning notes, formulas, and examples

About the Quaternion Calculator

Quaternions are a four-dimensional extension of complex numbers, discovered by William Rowan Hamilton in 1843. A quaternion q = w + xi + yj + zk has one real component (w) and three imaginary components (x, y, z), where the basis elements satisfy i² = j² = k² = ijk = −1. Quaternion multiplication is associative but not commutative, making them uniquely suited for representing 3D rotations.

In computer graphics, robotics, aerospace engineering, and game development, unit quaternions are the preferred way to represent rotations because they avoid the gimbal lock problem that plagues Euler angles and are more compact and numerically stable than rotation matrices. A rotation of angle θ about a unit axis (ux, uy, uz) is represented by the quaternion q = cos(θ/2) + sin(θ/2)·(ux·i + uy·j + uz·k).

This calculator performs all fundamental quaternion operations: addition, Hamilton product (non-commutative multiplication), conjugation, inversion, and normalization. It also converts unit quaternions to axis-angle representation and generates the corresponding 3×3 rotation matrix. Component magnitude bars provide visual insight into the quaternion's structure.

Presets cover standard 90° and 180° rotations about coordinate axes, chained rotations (multiplying two rotation quaternions), the identity quaternion, and a general addition example. The components table and rotation matrix are computed from q₁ for immediate use.

The reference table summarizes Hamilton's multiplication rules, the conjugate and inverse formulas, and the rotation formula v' = q·v·q⁻¹. Whether you are implementing a game engine, programming a robot arm, or studying abstract algebra, quaternion arithmetic is an essential skill.

When This Page Helps

Quaternion arithmetic is notoriously tricky — multiplication is noncommutative (q₁q₂ ≠ q₂q₁), the product formula involves 16 terms, and converting between quaternions and axis-angle or Euler angles requires careful trigonometry. This calculator performs quaternion addition, subtraction, multiplication, conjugation, normalization, inversion, and axis-angle ↔ quaternion conversion with full step display. Game developers, robotics engineers, and aerospace analysts rely on quaternions for smooth, gimbal-lock-free 3D rotations, and the page removes the hand-calculation friction that usually slows quaternion work.

How to Use the Inputs

  1. Select an operation: add, multiply, conjugate, inverse, normalize, or axis-angle.
  2. Enter the four components (w, x, y, z) of q₁.
  3. For add/multiply, also enter q₂ components.
  4. Or select a preset rotation to populate the fields.
  5. Read the result components and norm from the output cards.
  6. Check the rotation matrix and component bars for visualization.
Formula used
q₁·q₂ = (w₁w₂−x₁x₂−y₁y₂−z₁z₂) + (w₁x₂+x₁w₂+y₁z₂−z₁y₂)i + (w₁y₂−x₁z₂+y₁w₂+z₁x₂)j + (w₁z₂+x₁y₂−y₁x₂+z₁w₂)k; q* = w−xi−yj−zk; q⁻¹ = q*/|q|²

Example Calculation

Result: Rotation: 90° about X-axis (1, 0, 0)

The quaternion cos(45°) + sin(45°)·i represents a 90° rotation about the X-axis. The axis-angle decomposition confirms the axis is (1,0,0) and the angle is 90°.

Tips & Best Practices

  • Quaternion multiplication is NOT commutative: q₁·q₂ ≠ q₂·q₁.
  • Unit quaternions (norm = 1) represent pure rotations.
  • Chaining rotations = multiplying their quaternions (rightmost applied first).
  • The conjugate negates the vector part: q* = w − xi − yj − zk.
  • For unit quaternions, the inverse equals the conjugate.

Why Quaternions Beat Euler Angles

Euler angles (φ, θ, ψ) are intuitive but suffer from gimbal lock: when the middle rotation reaches ±90°, two axes align and one degree of freedom is lost. This causes erratic behavior in animations and control systems. Quaternions avoid gimbal lock entirely because they represent rotations as points on the 4D unit hypersphere S³, which has no singularities. Interpolating between two quaternion rotations via Slerp (Spherical Linear Interpolation) produces smooth, constant-speed paths, unlike Euler angle interpolation which can wobble or take unexpected routes. Every modern game engine (Unity, Unreal) and robotics framework (ROS) uses quaternions internally for rotation representation.

Quaternion Algebra

Quaternions extend complex numbers with three imaginary units i, j, k satisfying Hamilton's relations: i² = j² = k² = ijk = −1. From these, ij = k, jk = i, ki = j (and their reverses are negated: ji = −k, etc.), which is the source of noncommutativity. A quaternion q = w + xi + yj + zk has a scalar part w and a vector part (x,y,z). The product of two quaternions q₁q₂ encodes the composition of two rotations. The conjugate q* = w − xi − yj − zk is used for inversion: q⁻¹ = q*/|q|². Unit quaternions (|q| = 1) form the group Sp(1), which double-covers SO(3) — meaning q and −q represent the same rotation.

Converting Between Representations

To convert an axis-angle rotation (û, θ) to a quaternion: q = cos(θ/2) + sin(θ/2)(ûₓi + ûᵧj + ûᵨk). The reverse extracts θ = 2 arccos(w) and û = (x,y,z)/sin(θ/2). Converting quaternion → rotation matrix produces a 3×3 matrix whose entries are quadratic in the quaternion components, with no trigonometric functions required. Euler angle ↔ quaternion conversion depends on the rotation order (XYZ, ZYX, etc.) and requires chaining three half-angle quaternions. This calculator handles axis-angle ↔ quaternion conversion directly, and the step-by-step display clarifies the half-angle trigonometry that confuses many students.

Sources & Methodology

Last updated:

Frequently Asked Questions

  • A quaternion q = w + xi + yj + zk is a four-component number extending complex numbers, where i² = j² = k² = ijk = −1.