Visualizations
205 / 500

205 · 3D

Knot Table

Prime knots up to seven crossings, relaxed as tubes, with live Alexander polynomials.

Each knot from the trefoil to 7_7 starts as the closure of its braid word and relaxes under a repulsive knot energy: far-apart points push each other away like a discrete Moebius energy, edge lengths are held by position-based constraints, and a hard minimum distance between strands (the tube's thickness) means the curve can never pass through itself, so the knot type cannot change. The invariant is computed from what you see: the curve is projected, every crossing is found by segment intersection, the diagram is cut into arcs at the undercrossings, and the Alexander matrix is evaluated at roots of unity with complex elimination, then an inverse DFT turns the values back into integer coefficients. Turn or tangle the knot and the diagram changes completely, but the polynomial always matches the table.

Try it. Pull a strand to tangle the knot and let go to watch it relax. Drag the background to turn it, pick a knot from the table (or use the left and right arrows), press T to shake it up and R to rebuild it from its braid.

  • Repulsive knot energy
  • Position-based constraints
  • Alexander polynomial via DFT
  • Painter's algorithm tubes

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 knot relaxation toy 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 warm off-white background.
- Represent a knot as a closed loop of about 120 points in 3D. Start with a trefoil from the formula x = sin t + 2 sin 2t, y = cos t - 2 cos 2t, z = -sin 3t.
- Relax it each frame: every pair of points that are far apart along the loop pushes apart with a force proportional to 1 / distance squared, neighbours are pulled back to a fixed spacing, and a small smoothing term averages each point with its neighbours. Never let two distant points get closer than a minimum distance, so the strand cannot pass through itself.
- Rotate the loop slowly and draw it as a thick dark polyline in perspective.
- Let the user drag a point to pull the strand, and let go to watch it relax.

Once that works, make it beautiful:
- Draw the loop as a shaded tube: rings of vertices around each point, quads between rings, backface culling, Lambert plus specular shading, and a depth sort so near quads are painted last.
- Add a soft blurred shadow under the knot and a two-tone color gradient along the strand.
- Add buttons for a few more knots, such as the figure-eight and the (2, 5) torus knot.

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 detecting the crossings of the 2D projection, computing the Alexander polynomial from those crossings, or building knots from braid words.
PreviousMagnetic PendulumA pendulum over three magnets, and the fractal map of where every release point ends up. NextCPU PipelineA five-stage RISC pipeline as an isometric factory: bubbles, bypasses and flushes.

Related visualizations

  • Celtic KnotworkGenerative art Manuscript knot panels woven from a grid of breaks. Click to reweave the threads.
  • Tensegrity3D Struts that never touch, floating in a web of cables, found by dynamic relaxation.
  • Hopf Fibration3D The 3-sphere as linked circles, projected into nested tori of pastel rings.
  • Root BraidsMath Loop a quintic's coefficients and its roots braid, swap and refuse to come home.
  • Tutte EmbeddingAlgorithms A hopeless tangle of edges relaxes into a crossing-free drawing, as Tutte proved it must.
  • Indra's PearlsFractals Limit sets of Kleinian groups, strung as glowing necklaces of nested circles and pearls.
  • Apollonian GasketFractals An endless packing of kissing circles, each engraved with its exact integer curvature.
  • Elliptic CurvesMath Chord-and-tangent addition on a real curve, rolled up into the finite-field torus.
  • Four-Dimensional PolytopesMath All six regular 4D polytopes, double-rotating through themselves in stereographic 3D.

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

← More from Emergent Mind Labs