Quaternions extend complex numbers into four dimensions. Unit quaternions provide a compact, stable way to represent and combine rotations in three-dimensional space.
This is one self-contained HTML file. All styling and calculations are embedded as CSS and plain JavaScript. It needs no installation, web server, framework, or internet connection. Use your browser's Print command to save a PDF.
Complex numbers gave mathematicians an algebra for planar rotations. William Rowan Hamilton spent years trying to find an analogous multiplication for ordered triples, but three components were not sufficient.
Hamilton realized that the system required one real component and three imaginary components. He later wrote that he cut the defining formula into a stone at Brougham—now Broome—Bridge in Dublin.
Hamilton presented the discovery to the Royal Irish Academy on 13 November 1843 and published his 736-page Lectures on Quaternions in 1853.
Quaternions became central to inertial navigation, spacecraft attitude, robotics, computer graphics, animation, games, and sensor fusion.
Think of q=(w,x,y,z) as a four-number package. The first number is scalar. The final three act like a vector. When the package has length one, it can encode a pure 3-D rotation.
It is tied to the rotation angle, but it is not the angle itself. For a small turn, w is close to one.
Its direction is the rotation axis. Its length stores the sine of half the angle.
A quaternion is a package of four real numbers. Write q=(w,x,y,z). The first number is the scalar part. The last three form the vector part. A unit quaternion can encode a 3-D rotation.
ℍ is a four-dimensional associative division algebra over ℝ with basis 1,i,j,k. It is noncommutative: ij=k but ji=−k. Every nonzero quaternion has a multiplicative inverse.
The scalar term contains a dot product; the vector term contains a cross product. Reversing the order reverses that cross-product term.
| × | i | j | k |
|---|---|---|---|
| i | −1 | k | −j |
| j | −k | −1 | i |
| k | j | −i | −1 |
Reverses the vector part.
Multiplicative: ‖qr‖=‖q‖‖r‖.
For a unit quaternion, q⁻¹=q̄.
q₁ acts first under this page's convention.
Select unit axis û and right-handed angle θ.
Its norm is one, so q lies on S³.
The vector part of p′ is the rotated vector.
The signs cancel. Unit quaternions form Spin(3), a double cover of SO(3): every physical orientation corresponds to two antipodal points on S³.
Expand qpq⁻¹ and the result is Rodrigues' formula:
The component parallel to the axis stays fixed; the perpendicular component turns through θ.
Spherical linear interpolation follows a great-circle path on S³ at constant angular speed.
If q₀·q₁<0, implementations usually negate one endpoint to select the shorter equivalent path.
Euler angles lose a coordinate degree of freedom when two axes align. Unit-quaternion orientation has no such singularity. Physical gimbals can still lock, and converting back to Euler angles still encounters the Euler-coordinate singularity.
| Property | 3-D vector | Quaternion |
|---|---|---|
| Components | (x,y,z) | (w,x,y,z) |
| Main meaning | Direction and magnitude: position, velocity, force, or axis | A member of ℍ; when unit length, a 3-D orientation |
| Products | Dot product gives a scalar; cross product gives a vector | Hamilton product gives another quaternion and includes both dot and cross products |
| Rotation role | The object being rotated or the rotation axis | The operator that rotates the vector via q(0,v)q⁻¹ |
| Order | Addition commutes; cross product changes sign when reversed | qr generally differs from rq |
| Interpolation | Linear interpolation is common | Normalized lerp or SLERP is used for orientation |
All calculator results update when you press the associated button. Decimal input is accepted. Rotation tools normalize the quaternion automatically.
Enter q = (w,x,y,z) and r = (w,x,y,z).
Axes and quaternions are normalized automatically.
Computes q(0,v)q⁻¹.
Uses aerospace-style active Rz(yaw)Ry(pitch)Rx(roll), column vectors.
Attitude determination, inertial navigation, star-tracker filtering, guidance, control, and coordinate-frame transformations.
End-effector orientation, pose estimation, inverse kinematics, motion planning, and sensor fusion.
Camera orientation, skeletal joints, keyframe interpolation, virtual reality, and game-engine transforms.
Camera pose, bundle adjustment, simultaneous localization and mapping, and 3-D reconstruction.