ℍ

Quaternions and Dual Quaternions: Rotations, Screws and the Space Between

Complex numbers rotate the plane, quaternions rotate 3D, and dual quaternions rotate and translate at once. A playground for all three, and why conformal geometric algebra subsumes them.

·9 min read

Complex numbers rotate the plane. Quaternions rotate three-dimensional space. Dual quaternions rotate and translate at the same time, and the motion they describe is a screw: a rotation about an axis combined with a slide along that axis.

Each step adds one algebraic idea and removes one geometric headache. Complex multiplication replaces a 2D rotation matrix. Quaternion multiplication replaces a 3D rotation matrix, with no Euler angles and no gimbal lock. A dual quaternion replaces a rotation-plus-translation pair with one object that can be composed and interpolated directly.

The playground below has three tabs: Complex, Quaternion and Dual quaternion. Each one shows the algebra and the geometry at the same time.

The Playground

ℂ · ℍ · ℍ[ε]
rotation + slerp

unit quaternion

q₁0.50 +0.64i +0.37j +0.45k
q(t)0.78 +0.47i +0.27j +0.33k
axis u(0.74, 0.42, 0.52)
angle120°

rotate a vector

v′q v q*
q(t)slerp(1, q₁, 0.65)

A unit quaternion is a rotor. Composition is multiplication; interpolation is slerp. The quaternion and its negative encode the same rotation.

A few things to try:

  • In Complex, move the angle and magnitude sliders. The cyan vector vv is multiplied by zz; the fuchsia vector is zvzv. Multiplication is a rotation plus a uniform scale, and the readout shows the corresponding 2×22 \times 2 matrix.
  • In Quaternion, change the rotation axis and angle. The faint craft is the identity pose, the amber wireframe is the target pose, and the cyan craft is the slerp between them. Slide tt to watch the interpolation.
  • In Dual quaternion, add a translation. The object now rotates and moves. Slide tt: the path is a helix around the green screw axis, not a straight line with a separate rotation.
  • Set the dual-quaternion rotation angle to zero. The motion becomes a pure translation, and the screw axis is the direction of travel.
  • Set the translation to zero. The motion becomes a pure rotation, and the screw axis passes through the origin.
  • Compare the quaternion and dual-quaternion tabs. The quaternion has three degrees of freedom; the dual quaternion has six.

Complex Numbers: The First Rotor

A complex number is a pair of reals with the rule i2=−1i^2 = -1:

z=a+bi.z = a + bi.

Multiplying two complex numbers is

(a+bi)(c+di)=(ac−bd)+(ad+bc)i.(a+bi)(c+di) = (ac-bd) + (ad+bc)i.

If z=r(cos⁡θ+isin⁡θ)z = r(\cos\theta + i\sin\theta), then multiplication by zz rotates by θ\theta and scales by rr. The unit complex numbers, ∣z∣=1|z|=1, form the circle group and act as the rotations of the plane. In matrix form,

z⟷(a−bba).z \longleftrightarrow \begin{pmatrix} a & -b\\ b & a \end{pmatrix}.

This is the first example of a rotor: an algebraic object that acts on vectors by conjugation or multiplication, with composition given by the same multiplication. Complex numbers are the even subalgebra of the 2D Clifford algebra Cl(2,0)Cl(2,0); the bivector e1e2e_1e_2 plays the role of ii.

Complex numbers are also the reason 2D conformal maps are so pleasant: a holomorphic function is locally a complex multiplication, hence a rotation and a scale. We explored that in Conformal Maps.

Quaternions: Rotations in Three Dimensions

Hamilton's quaternions extend the complex numbers with three imaginary units:

q=w+xi+yj+zk,q = w + xi + yj + zk,

subject to

i2=j2=k2=ijk=−1.i^2 = j^2 = k^2 = ijk = -1.

The multiplication is associative but not commutative. The conjugate is

q∗=w−xi−yj−zk,q^* = w - xi - yj - zk,

and the norm is ∣q∣=qq∗|q| = \sqrt{q q^*}. A unit quaternion, ∣q∣=1|q|=1, encodes a rotation. For a unit axis uu and an angle θ\theta,

q=cos⁡θ2+sin⁡θ2(uxi+uyj+uzk).q = \cos\frac{\theta}{2} + \sin\frac{\theta}{2}(u_x i + u_y j + u_z k).

To rotate a vector vv, treat it as the pure quaternion v=0+vxi+vyj+vzkv = 0 + v_x i + v_y j + v_z k and conjugate:

v′=qvq∗.v' = q v q^*.

The result has zero scalar part; its vector part is the rotated vector. The half-angle is not a typo. It is what makes the double cover work: qq and −q-q represent the same rotation, and a full 360∘360^\circ rotation is a path from qq to −q-q, not back to qq.

Two rotations compose by multiplying their quaternions. Interpolation uses slerp:

q(t)=sin⁡((1−t)Ω)sin⁡Ωq0+sin⁡(tΩ)sin⁡Ωq1,q(t) = \frac{\sin((1-t)\Omega)}{\sin\Omega}q_0 + \frac{\sin(t\Omega)}{\sin\Omega}q_1,

where Ω\Omega is the angle between the two unit quaternions. Slerp follows the shortest arc on the unit sphere. The playground's tt slider is exactly this interpolation.

Quaternions are the even subalgebra of the 3D Clifford algebra Cl(3,0)Cl(3,0). The bivectors e2e3e_2e_3, e3e1e_3e_1, e1e2e_1e_2 square to −1-1 and anticommute, just like i,j,ki,j,k. A unit quaternion is a rotor; a rotation matrix is what you get if you insist on coordinates.

Dual Quaternions: Rotation and Translation Together

A dual number extends the reals with a nilpotent element:

ε2=0,ε≠0.\varepsilon^2 = 0, \qquad \varepsilon \ne 0.

It is the algebra of the Taylor expansion

f(x+ε)=f(x)+f′(x)ε,f(x+\varepsilon) = f(x) + f'(x)\varepsilon,

and it is the engine behind forward-mode automatic differentiation.

A dual quaternion is a quaternion with quaternion coefficients in the dual numbers:

q=qr+εqd.q = q_r + \varepsilon q_d.

The real part qrq_r is a rotation quaternion. The dual part qdq_d carries the translation. For a translation vector tt,

qd=12tqr,q_d = \tfrac12 t q_r,

where tt is treated as the pure quaternion 0+txi+tyj+tzk0 + t_x i + t_y j + t_z k. The unit conditions are

qrqr∗=1,qrqd∗+qdqr∗=0.q_r q_r^* = 1, \qquad q_r q_d^* + q_d q_r^* = 0.

A point pp is embedded as 1+εp1 + \varepsilon p, and the rigid transform is

p′=q(1+εp)q−1,q−1=qr∗−εqd∗.p' = q (1 + \varepsilon p) q^{-1}, \qquad q^{-1} = q_r^* - \varepsilon q_d^*.

Expanding this gives the familiar rotation-plus-translation formula:

p′=qrpqr∗+t.p' = q_r p q_r^* + t.

The translation can also be read directly from the dual part:

t=2vec⁡(qdqr∗).t = 2\operatorname{vec}(q_d q_r^*).

This is the whole trick. A dual quaternion is not a rotation and a translation stored side by side; it is one unit object whose multiplication composes rigid transforms and whose interpolation moves the object along a screw.

The Screw Axis

Chasles' theorem says every rigid motion in 3D is a rotation about some axis plus a translation along that axis. That axis is the screw axis, and the ratio of axial translation to rotation angle is the pitch.

Given a unit dual quaternion, the screw parameters are:

θ=2atan2⁡(∣v∣,w),l=v∣v∣,\theta = 2\operatorname{atan2}(|v|, w), \qquad l = \frac{v}{|v|},

where qr=w+vq_r = w + v and v=vxi+vyj+vzkv = v_x i + v_y j + v_z k. The translation is t=2vec⁡(qdqr∗)t = 2\operatorname{vec}(q_d q_r^*). Decompose it into

t∥=(t⋅l)l,t⊥=t−t∥.t_\parallel = (t\cdot l)l, \qquad t_\perp = t - t_\parallel.

Then

h=t⋅lθ,p=12(t⊥+cot⁡θ2 l×t⊥),h = \frac{t\cdot l}{\theta}, \qquad p = \tfrac12\left(t_\perp + \cot\frac{\theta}{2}\, l \times t_\perp\right),

where pp is the point on the screw axis closest to the origin. The transform after fraction uu of the motion is a rotation by uθu\theta about the axis through pp, plus a translation uhθu h \theta along ll.

That is what the playground draws: the green line is the screw axis, the orange path is the helix traced by the nose of the craft, and the pitch readout is hh. When the rotation angle is zero, the axis is at infinity and the motion is a pure translation. When the translation is zero, the pitch is zero and the motion is a pure rotation.

Dual quaternions are used for rigid-motion interpolation, character skinning, hand-eye calibration and robot trajectory blending. They avoid the shrinking and candy-wrapper artifacts of naive matrix blending, and they keep every interpolated transform rigid.

Quaternions Are Clifford Algebra in Disguise

The pattern is not a coincidence.

AlgebraSignatureWhat it describes
Complex numbers C\mathbb{C}Cl+(2,0)Cl^+(2,0)2D rotations and scales
Quaternions H\mathbb{H}Cl+(3,0)Cl^+(3,0)3D rotations
Dual quaternions H[ε]\mathbb{H}[\varepsilon]quaternions plus dual numbersrigid motions and screws
Conformal geometric algebraCl(4,1)Cl(4,1)points, spheres, planes, circles, lines, intersections, rotors

Complex numbers are the even part of the 2D Clifford algebra. Quaternions are the even part of the 3D Clifford algebra. Dual quaternions combine quaternions with a nilpotent direction. Each is a different specialization of the same geometric product.

Conformal Geometric Algebra: One Algebra to Hold Them All

Quaternions and dual quaternions are excellent when the problem is rotation or rigid motion. Conformal geometric algebra (CGA) takes a different approach: it embeds 3D Euclidean space in a 5D space with signature (4,1)(4,1), and then represents everything with the same product.

In CGA:

  • points are null vectors,
  • circles, lines, spheres and planes are blades,
  • intersections are meets,
  • rotations and translations are rotors.

There is no separate translation vector and no dual-unit constraint. A point is X=x+12∣x∣2e∞+e0X = x + \tfrac12|x|^2 e_\infty + e_0, and a rigid motion is a rotor acting by X↦RXR~X \mapsto R X \tilde R. The same meet operation that intersects two spheres also intersects a line with a plane. The same algebra that rotates a vector translates a point.

The price is dimension and bookkeeping. The reward is one vocabulary for geometry, motion and intersection. Quaternions and dual quaternions are the fast, compact tools for rotations and rigid motions; CGA is the larger language that subsumes these constructions under one notation.

💡

The companion article Conformal Clifford Algebra builds the 5D model from scratch, with a playground for N-joint inverse kinematics and sphere/plane/circle intersections. It is the natural next step after dual quaternions.

Further Reading

  • William Rowan Hamilton, Lectures on Quaternions — the original, surprisingly readable source.
  • Andrew Hanson, Visualizing Quaternions — the best geometric intuition for quaternion curves and frames.
  • Ken Shoemake, Animating Rotation with Quaternion Curves — the paper that brought slerp to computer graphics.
  • Ladislav Kavan et al., Dual Quaternions for Rigid Transformation Blending — the standard reference for dual-quaternion skinning.
  • Leo Dorst, Daniel Fontijne and Stephen Mann, Geometric Algebra for Computer Science — how quaternions, dual numbers and CGA fit into one Clifford algebra.
  • The Conformal Clifford Algebra article on this site.

Related Articles

◆
·18 min read

Automatic Differentiation

A deep-dive into automatic differentiation: symbolic vs. numerical vs. AD, AST transformation, dual numbers, tapes, hybrid methods, and a generic C++ implementation that computes gradients and solves optimisation problems.