Wind a thread p times around the ring and q times through its hole and it closes into a knot — the trefoil is (2,3). The secret: on the flat torus that same knot is just a straight line, and whether it’s one knot or several depends only on whether p and q share a factor. Slide q (or tap) and watch it braid.
A (p, q) torus knot. Parametrise φ=p·θ around the axis and ψ=q·θ around the tube: x=(R+r·cosψ)cosφ, y=(R+r·cosψ)sinφ, z=r·sinψ, θ∈[0,2π]. Since √(x²+y²)=R+r·cosψ, every point satisfies (√(x²+y²)−R)²+z²=r² EXACTLY — the curve lies on the torus, provably. It closes after winding p times around and q times through, and the number of separate loops is gcd(p, q): coprime p, q give a single true knot (p=2 fixed, so odd q are knots, even q are 2-component links). On the unrolled flat torus the knot is a straight line of slope q/p — drawn live in 2D. A fail-loud self-check throws unless every sampled point is on the torus to 1e-9 and gcd sets the component count.
A geometric idealisation (a mathematical curve, zero thickness); real knots have a tube and a crossing number. The on-torus identity, the closure and gcd(p,q)=components are exact.