Torus knot

Torus knot preview
remixableManimCE3Dtopologyturntable

manim/torus_knot.py

"""Torus knot: a (2, 3) trefoil drawn as a tube, the spectrum running along it.

The tube is a Surface over (u, v): u walks the knot, v walks round the tube's
cross-section. Each face is coloured by u, so the hue follows the strand and
you can trace it through every crossing by colour alone, and shaded by how
far its normal turns from the light so the tube reads as round.

The cross-section frame is built from the tangent and the vertical rather
than the Frenet frame. Frenet flips where the curvature passes through zero
and twists the tube's faces into a visible seam; this knot's tangent never
points straight up, so crossing it with z is always well defined.

The catalog's `pq` toggle cycles the knot type, which is a different body
rather than something to composite over this one, so it ships no PNG. The
loop is the default orbit spin: turning the camera round a fixed knot and
turning the knot under a fixed camera are the same eight seconds.

The full Manim source and the rendered video come with a plan.