Apollonian gasket
In the chaos game, a point jumps halfway toward a randomly chosen vertex, tracing the Sierpiński triangle. What happens when we change the jump rule? In this demo, circle inversions trace the Apollonian gasket, while exact circles reveal where the points accumulate.
Previous episode: the chaos game
Video walkthrough
From gap to circle
Put three equal circles inside a larger circle. Each touches its two neighbours and the outer boundary. Three arcs bound each remaining gap. Inscribe a circle tangent to all three boundaries. This splits the gap into three smaller gaps where the same rule applies.
How the point jumps
An inversion has a circle with centre O and radius R. It sends a point P to P′ on the same ray from O, with OP × OP′ = R². We use four inversion circles. Each passes through the three points of tangency of one triple from the initial four packing circles.
Why the points follow the pattern
An inversion preserves the three chosen packing circles and maps the fourth to the other circle tangent to the triple. These inversions preserve the entire packing. A point starting on the outer boundary therefore stays on a circle of the packing. The demo picks one of four rules at random and skips an immediate repeat, which would send the point straight back. The seed lets you reproduce the same sequence.
What the overlay reveals
The point plot builds up gradually. Some arcs emerge before others. The circle layer builds level by level and draws each located circle in full. The finite overlay shows only the first few levels, while points can also land on the boundaries of smaller circles.
One inversion step
function invert(point, mirror) {
const dx = point.x - mirror.x;
const dy = point.y - mirror.y;
const scale = mirror.radius ** 2 / (dx * dx + dy * dy);
return {
x: mirror.x + dx * scale,
y: mirror.y + dy * scale
};
}