Embed 3D geometry in a 5D Clifford algebra where points, circles, spheres, planes and lines are all blades. A playground for N-joint inverse kinematics, curve and surface intersections.
Many hard 3D problems become linear once you embed them in the right pseudo-Euclidean space. Complex numbers make 2D rotations into multiplication. Quaternions do the same for 3D rotations. Dual numbers make derivatives into multiplication. Conformal geometric algebra (CGA) extends the trick to points, spheres, planes, circles, lines and rigid motions.
This post is a tour of that algebra, with a playground: a robot arm you can steer, and a geometry sandbox where spheres, planes and circles intersect as multivectors.
The Playground
The panel below has two modes. Arm / IK is a 3D chain of joints tracking either the mouse or a moving path. Curves & surfaces constructs circles, spheres, planes and lines as CGA blades, intersects them, and prints the multivector arithmetic behind the result.
Drag to orbit, scroll to zoom. In the arm mode, move the pointer over the canvas to move the target. Switch to Path to make the arm chase a Lissajous curve, a trefoil or an orbit. The sliders control the number of joints, the segment length, the number of CCD iterations and the damping. The little graph in the corner is the live end-effector error.
A few things to try:
- In Curves & surfaces → sphere ∩ sphere, pull the centre offset apart until the two spheres separate. The circle shrinks to a point and then the meet disappears.
- In sphere ∩ plane, tilt the plane past the sphere's edge. The circle radius goes to zero and becomes imaginary.
- In circle ∩ plane, slide the plane through the circle. The meet is a point pair; when the plane misses the circle it becomes an imaginary point pair.
- In line ∩ sphere, move the line off the sphere. The point pair vanishes.
- In plane ∩ plane, make the planes parallel. The line at infinity is the only thing left, and the grade readout tells you the meet is degenerate.
- In Arm / IK, set the joints to 8, the damping to about 0.7, and let it chase the trefoil. Increase the iterations if the error graph is noisy; decrease them to see the lag.
The Rules in One Page
A Clifford algebra starts with a vector space and a quadratic form. The geometric product of vectors is
The dot product is the symmetric part; the wedge is the antisymmetric part. For CGA we take the Euclidean basis and add two directions with
The signature is . Define the null combinations
so that
A Euclidean point is the null vector
Then and
Distance has become an inner product.
Wedge products build the objects. One point is a point; two points give a point pair; three give a circle; four give a sphere. Adding changes a circle into a line and a sphere into a plane. The grade of the blade is the type of the object.
Every blade has a dual,
The intersection of two blades is their meet:
The grade of the result says what the intersection is: 3 for a circle or a line, 2 for a point pair, 1 for a point, and 0 for no real intersection.
A rotation is a rotor,
acting on any multivector by conjugation:
The rotor taking a unit vector to a unit vector is
That is the language. The rest of the post explains where it comes from, why it works, and how the playground uses it.
Where These Algebras Come From
Clifford algebra — also called geometric algebra — is the common ancestor of several familiar number systems. The pattern is always the same: choose a vector space, choose a quadratic form, and let the geometric product do the rest.
Euclidean space. Ordinary 3D vectors have a dot product and a cross product. The dot product measures projection; the cross product produces an axis perpendicular to two vectors. The cross product is special to three dimensions, and it forces rotations to be described separately: matrices, Euler angles, or quaternions. Clifford algebra keeps the dot product and adds the wedge product; the cross product is the dual of the wedge, which is why it only exists in three dimensions.
Complex numbers. The even subalgebra of the 2D Clifford algebra is isomorphic to . The bivector squares to , so it plays the role of . Multiplication by a complex number is a rotation followed by a scale, and Euler's formula is the simplest rotor. This is why complex analysis is the natural language of 2D conformal maps.
Quaternions. The even subalgebra of the 3D Clifford algebra is isomorphic to the quaternions . The three bivectors , , square to and anticommute, exactly like . Unit quaternions are rotors: composition is multiplication, interpolation is slerp, and there is no gimbal lock because there are no Euler angles to lock.
Dual numbers. The algebra with a nilpotent generator is the Clifford algebra of a degenerate one-dimensional quadratic form. It gives the Taylor expansion
which is the entire idea behind forward-mode automatic differentiation. The automatic differentiation article on this site is the same trick in a different signature.
One product, many geometries. Change the signature and the same product describes a different geometry. is Euclidean space, is spacetime, and is the conformal model of 3D Euclidean space. Complex numbers, quaternions and dual numbers are not separate miracles; they are shadows of one product.
The payoff is not only unification. In spacetime algebra , the four Maxwell equations collapse into one equation (up to constants):
where is the Faraday bivector — electric and magnetic fields in one object — and is the four-current. The geometric product contains both a divergence and a curl; its trivector part gives the homogeneous pair, and its vector part gives the sourced pair. The four equations did not disappear. They became components of one multivector equation.
For a playground that walks through the rotation-only part of this story — complex numbers, quaternions and dual quaternions — see Quaternions and Dual Quaternions.
Blades Are Geometry
A blade is a wedge product of vectors. In CGA, wedging points gives the smallest linear subspace containing them, and the null vectors inside that subspace are the geometric object.
| Euclidean object | CGA blade | Grade |
|---|---|---|
| point | 1 | |
| point pair | 2 | |
| circle | 3 | |
| line | 3 | |
| sphere | 4 | |
| plane | 4 | |
| whole space | 5 |
A circle through three points is literally the wedge of those points:
A sphere through four points is
A plane through three points needs the point at infinity, because a plane is a circle through infinity:
A line through two points is
This is why CGA feels like a geometry language rather than a numerical library. The constructions are not algorithms with branches; they are exterior products. The grade tells you what kind of object you built.
Duality: Spheres and Planes as Vectors
Every blade has a dual. In 5D,
The dual of a sphere is a vector. With centre and radius ,
For any point ,
So the sphere equation is the linear equation . A plane has an even simpler dual:
where is the unit normal and the plane is . The sign of is the signed distance from the point to the plane (up to scale).
This duality is the reason CGA is so compact. A sphere is a vector in the dual picture. A plane is a vector. A circle is a grade-3 blade in the primal picture, and a grade-2 blade after dualising. A point pair is grade 2. Lines and circles are both grade-3 primal blades, distinguished by whether they contain .
Intersections Are Meets
The intersection of two blades is their meet, computed with the dual and the left contraction:
The grade of the result tells you what happened:
| Meet | Grade | Result |
|---|---|---|
| sphere sphere | 3 | circle |
| sphere plane | 3 | circle |
| plane plane | 3 | line |
| circle plane | 2 | point pair |
| line sphere | 2 | point pair |
| line plane | 2 | point pair (finite point + ) |
| point anything | 1 | point |
The playground uses exactly this formula. For a grade-3 result it checks whether the blade contains : if it does, the result is a line; otherwise it is a circle. For a grade-2 result it extracts the two null directions of the point-pair blade. For a grade-1 result it extracts the point.
Extracting a circle from a grade-3 blade is a nice exercise in duality. If is the circle blade, then is a 2-blade. The circle's plane is the unique vector in orthogonal to . The sphere is times that plane vector. Reading the centre and radius from the dual sphere vector then gives the circle. The playground does this numerically, which is why the readout can print a centre and a radius even though the input was three points.
Degenerate meets are real. A tangent sphere and plane give a circle of radius zero. Two nested spheres give an imaginary circle. Parallel planes give a line at infinity. Two circles that share two points are not transversal as blades, so the naive regressive product can vanish; in that case you intersect one circle with the other's supporting plane. The algebra is honest about all of these cases, but you still have to handle them in code.
Rotors: The Only Transformation You Need
A rotor is an even multivector with . It acts on any multivector by conjugation:
For a Euclidean rotation, pick a unit bivector (the plane of rotation) and an angle :
In 3D, bivectors are dual to axes, and rotors are quaternions up to sign. The formula is dimension-independent: the same expression works in 2D, 3D, 4D and in the 5D conformal model.
The rotor that takes a unit vector to a unit vector is even simpler:
There is no Euler angle, no rotation matrix, no gimbal lock. Composition is multiplication: . Interpolation is slerp on the bivector part, which is exactly what the playground's damping slider does.
A Euclidean rotor fixes the two null basis vectors:
So if is null, is null too:
Rotors move points on the null cone without leaving it. That is the property inverse kinematics needs.
Inverse Kinematics with Rotors
An -joint arm is a chain of points , with fixed segment lengths. The base is anchored. The end effector is , and the target is .
The algorithm in the playground is cyclic coordinate descent (CCD), written entirely with CGA rotors. For each joint from the wrist back to the base:
- Let be the current direction from the joint to the end effector.
- Let be the direction from the joint to the target.
- Build the rotor .
- Rotate every downstream joint around by .
In code, with conformal points and a pivot:
for (let iter = 0; iter < iterations; iter++) {
for (let j = N - 1; j >= 0; j--) {
const u = normalize(sub(end, joint))
const v = normalize(sub(target, joint))
const R = rotorFromTo(u, v) // (1 + v u) / |1 + v u|
const Rα = rotorSlerp(R, damping) // optional damping
for (let k = j + 1; k <= N; k++) {
const rel = sub(arm[k], joint)
const X = point(rel) // conformal point
const Y = applyRotor(Rα, X) // R X R̃
arm[k] = add(joint, extractPoint(Y))
}
}
}Each joint rotation is a rigid rotation of the downstream chain, so it cannot change segment lengths. CCD is a local method: it reduces the error at each step and usually converges in a few iterations, but it can stall in awkward configurations. That is what the damping and iteration sliders expose.
The CGA part is not cosmetic. The rotor is built from Euclidean direction vectors, but it is applied to conformal points. Because the rotor fixes and , the transformed point stays on the null cone. The pivot is handled by moving the point to the joint, rotating, and moving it back. In CGA that translation is itself a rotor, ; the playground uses the equivalent Euclidean shift for speed.
If the target is outside the arm's reach, clamp it to the sphere of radius equal to the total segment length. The playground does this every frame. Without it, CCD keeps stretching toward an impossible point and the error graph becomes a flat line.
Tracking a Path
Mouse tracking is a sequence of independent targets. Path tracking is a sequence of targets with momentum. The playground runs a few CCD iterations per animation frame, so the arm is always solving a slightly stale problem. That is exactly what a real controller does.
The path is a parametric curve . The playground offers three:
- a Lissajous curve, , , ;
- a trefoil, a closed knot with threefold symmetry;
- an orbit, a tilted ellipse with a small out-of-plane wobble.
The target path is drawn as a dashed line. The trail is the end effector's actual path. The gap between them is the tracking error, and the little graph shows it over the last few seconds.
A nice experiment: set the joints to 4 and the segment length to 0.5, then try to track the trefoil. The arm runs out of reach, the target gets clamped to the reach sphere, and the error graph shows the boundary. Add joints until the error drops. This is the difference between "the solver works" and "the arm can actually reach the curve".
What the Playground Is Doing
The geometry tab builds each object as a CGA blade and then calls the same meet function.
For sphere ∩ sphere, the two spheres are dual vectors; their meet is a grade-3 circle blade. The circle is drawn from the extracted centre, radius and normal.
For sphere ∩ plane, the sphere is a dual vector and the plane is a dual vector. The meet is again a circle. Tilt the plane and the circle moves; push the plane past the sphere and the radius goes imaginary.
For circle ∩ plane, the circle is built as from three points. The plane is a dual vector. The meet is a grade-2 point pair; the two points are the null directions in the blade's span.
For line ∩ sphere, the line is . The meet with the sphere is a point pair. Move the line until it misses the sphere and the point pair becomes imaginary.
For plane ∩ plane, both planes are dual vectors. The meet is a line; when the planes are parallel the line escapes to infinity and the extractor reports no finite line.
The readout at the bottom of the canvas shows the grade of the meet and the extracted Euclidean data. That grade is the type signature of the intersection. Below the controls, the algebra panel prints the actual multivector coefficients in the basis: the primal blades for and , the dual , and the contraction that produces the meet. Move a slider and watch the coefficients change; the grade of tells you when the intersection changes type.
Implementation: A 32-Component Kernel
The playground uses a small CGA kernel in lib/cga.ts. A 5D multivector has coefficients, one per basis blade. The kernel precomputes a multiplication table and implements:
- the geometric product,
- the wedge product,
- grade projection and reverse,
- the dual ,
- the left contraction and the meet,
- point, sphere, plane, circle and line constructors,
- extractors for spheres, planes, circles, lines, point pairs and points,
- rotors and rotor slerp.
The core meet is three lines:
export function meet(a: MV, b: MV): MV {
return leftContract(dual(a), b)
}The point embedding is similarly small:
export function point(x: number, y: number, z: number): MV {
const r = new Float64Array(32)
r[E1] = x; r[E2] = y; r[E3] = z
const r2 = x*x + y*y + z*z
r[EP] = 0.5 * (r2 - 1)
r[EM] = 0.5 * (r2 + 1)
return r
}That is enough to run a 6-joint arm at 60fps with 8 CCD iterations per frame, and to draw the intersection of two spheres without a single trigonometric special case. The whole thing is dependency-free; the browser does the rest.
Where This Goes Next
Once the geometry is in one algebra, the extensions are natural:
- Joint limits become constraints on rotors, or intersections of allowed regions.
- Collision avoidance becomes distance queries between spheres, planes and capsules; the signed distance is an inner product.
- Vision and graphics use the same meet to triangulate points, fit circles and planes, and project.
- Dynamics can be written with rotors and screws; CGA contains rigid-body motions as rotors, and the conformal model adds translations for free.
- Higher dimensions are just more basis vectors. The formulas do not change; only the multiplication table grows.
The arm in the playground is deliberately simple: a serial chain, no joint limits, no obstacles. But the language is not simple. It is a uniform way to say "point", "circle", "sphere", "plane", "rotation" and "intersection" in the same algebraic sentence. That is the real payoff of conformal Clifford algebra: not a faster IK solver, but a smaller vocabulary.
Further Reading
- David Hestenes, New Foundations for Classical Mechanics — the classic geometric-algebra view of mechanics.
- Leo Dorst, Daniel Fontijne and Stephen Mann, Geometric Algebra for Computer Science — the standard engineering text, with a thorough treatment of CGA.
- Anthony Lasenby, Chris Doran and Stephen Gull, Gravity, Gauge Theories and Geometric Algebra — the physics side of the same formalism.
- Rich Wareham, Jonathan Cameron and Joan Lasenby, Applications of Conformal Geometric Algebra in Computer Vision and Graphics — a good entry point for the meet/join machinery.
- The Cambridge geometric algebra course has lectures and software that go much deeper than this playground.
Related Articles
Conformal Maps: When Complex Functions Preserve Angles
A conformal map preserves angles: near every point it behaves like a rotation followed by a uniform scaling. Explore them in a playground that warps grids and images — written with complex numbers, 2D vectors, and dual numbers.
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.

Hamilton: A Phase-Space Playground
Type a Hamiltonian or Lagrangian, integrate it in the browser, and watch an entire phase space evolve. A WebGL2 playground with RK4, symbolic derivatives and 21 built-in systems.
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.