Visualizations
023 / 500

023 · 3D

Hopf Fibration

The 3-sphere as linked circles, projected into nested tori of pastel rings.

The 3-sphere in four dimensions is a union of great circles, one over every point of an ordinary 2-sphere, and any two of them are linked exactly once. Each dot on the little base sphere picks a circle (its fiber), which is stereographically projected from S3 into space as an exact round ring: circles of latitude lift to nested tori, the equator to the Clifford torus ruled by Villarceau circles. Tube thickness follows the projection's conformal scale, faint bands slide along every fiber to show the circle action, and thousands of shaded quads are depth sorted and painted back to front.

Try it. Draw on the base sphere in the corner to add fibers, and hover its dots to pick out their rings. Drag to orbit, click or press Space for the next pattern (1 to 5 choose one), C clears, F pauses the flow.

  • Stereographic projection
  • Painter's algorithm tubes
  • Parallel transport frames
  • Circumcircle sampling

View the source · one module, plus a small shared runtime for sizing, the animation loop and input

Build your own

Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.

Build an interactive Hopf fibration viewer with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.

Start simple:
- Make a canvas that fills the window, stays sharp on high-DPI screens (scale by devicePixelRatio), and resizes with the window. Use a dark navy background.
- For a point (a, b, c) on the unit sphere, its Hopf fiber is the circle q(t) = ((1 + c) cos t, a sin t - b cos t, a cos t + b sin t, (1 + c) sin t) / sqrt(2 (1 + c)) on the 3-sphere in 4D. Sample it at about 100 values of t.
- Stereographically project each 4D point to 3D with (q1, q2, q3) / (1 - q0), rotate the 3D points with a slowly turning camera, and draw each fiber as a closed polyline in perspective.
- Pick 12 points around the equator of the base sphere and draw their fibers. You should see a ring of interlocking circles on a torus. Then add two more circles of latitude to get nested tori.
- Color each fiber by its base point, with the hue from its longitude, in soft pastels.

Once that works, make it beautiful:
- Turn each fiber into a tube: build a ring of 8 vertices around every sample point, make quads between neighbouring rings, skip quads that face away from the camera, shade each one with a Lambert term plus a small specular highlight, sort every quad of every tube by depth and fill them back to front.
- Make the tube thicker where (1 + |P|^2) / 2 is larger, so it looks like an evenly thick tube in 4D.
- Draw a small base sphere in a corner and let the user click or drag on it to add fibers.

Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as animating a 4D rotation before projecting, sliding colored bands along each fiber to show the circle action, or checking numerically that every pair of fibers has linking number one.
PreviousBonfireA campfire whose flames are a fluid simulation colored by blackbody physics. NextPainterly RenderingA harbor at dusk repainted coarse to fine in thousands of curved, bristly strokes.

Related visualizations

  • Four-Dimensional PolytopesMath All six regular 4D polytopes, double-rotating through themselves in stereographic 3D.
  • Dandelin Spheres3D Two spheres wedged in a sliced cone prove the focus property, with no algebra.
  • Tiny Planet3D A ray traced village panorama that curls into a tiny planet, a fisheye or a camera view.
  • Circle PackingMath Thurston's discrete Riemann map: a live circle packing warps a picture into your blob.
  • Slicing Four DimensionsMath A hyperplane sweeps through 4D shapes, leaving glassy 3D cross sections.
  • Apollonian GasketFractals An endless packing of kissing circles, each engraved with its exact integer curvature.
  • Spinning Donut3D A shaded torus rendered point by point with a homemade z-buffer.
  • Ford CirclesMath A circle for every fraction, and a dive into why the golden ratio is the most irrational.
  • Map ProjectionsMath One procedural planet morphing through a dozen map projections, Tissot ellipses and all.

Use ← and → to move between demos. While the canvas has focus, keys go to the demo instead.

← More from Emergent Mind Labs