07Mathematics · Graphicsexplorer

HorocyclePaint on the hyperbolic plane

What does a world look like where space grows faster the farther you go?

Horocycle on a desktop screen
Horocycle on a phone

Summary

Paint one motif and watch it tile the hyperbolic plane in real time; travel through it and measure triangles whose angles add up to less than 180°.

What you can do

  • Paint in one tile and the stroke appears in every tile of the infinite tiling at once.
  • Six {p,q} presets or any triangle group; switch reflection and rotation symmetry and keep your strokes.
  • Drag to travel through hyperbolic space with inertia; two-finger rotate on touch screens.
  • Poincaré disk, half-plane, Klein and band models with morphing transitions.
  • Measure geodesics, triangle angle sums and circles; export PNG up to 4096 px or share a link.

How it works

A WebGL2 fragment shader folds each pixel back into the fundamental triangle by repeated reflections across its sides, then samples the painted motif; the number of reflections gives the colouring. Travel is a Möbius isometry of the disk, re-centred on a symmetry so 32-bit floats stay accurate.

The hard part

Exact hyperbolic geometry at interactive frame rates in a shader, with painting, travel and model changes all staying consistent — verified to near machine precision.

Validation

Isometries preserve distance (100 000 samples)
worst relative error 3 × 10⁻¹³
Triangle angles π/p, π/q, π/r (12 075 triples)
3.6 × 10⁻¹⁵ rad
Gauss–Bonnet: integrated area vs π − angle sum
1.5 × 10⁻¹⁰
Circumference vs 2π sinh r
2.6 × 10⁻¹⁴ relative
Fold convergence (200 004 points)
0 failures

Built with

  • TypeScript
  • WebGL2
  • GLSL
  • MathML

Skills it demonstrates

  • Non-Euclidean geometry
  • Group theory
  • Shader programming