This simulator generates parametric meshes for three closed orientable surfaces — sphere, torus and double torus — classified by their genus g, the number of handles. Torus vertices follow ((R+r·cos v)·cos u, (R+r·cos v)·sin u, r·sin v); the sphere uses the standard spherical parametrization; the double torus stitches two toroidal tubes side by side as a visual stand-in for a genus-2 surface. Each vertex is rotated in 3D (drag or auto-spin) and projected with simple perspective d = fov/(fov+z). Wireframe, painter's-algorithm shaded, and fundamental-polygon views render the identical mesh differently, while a live panel reports genus g, Euler characteristic χ = 2−2g, and fundamental group π₁.
A rotating 3D mesh of the selected surface, switchable between wireframe (ring/meridian lines), shaded (quads sorted back-to-front with the painter's algorithm and z-tinted), and a 2D fundamental-polygon net — a square aba⁻¹b⁻¹ for the torus, a 2-gon aa⁻¹ for the sphere, and an octagon [a,b][c,d] for the double torus, with directional edge arrows showing which sides are glued together. A live fact-grid tracks genus g, Euler characteristic χ, orientability and the fundamental group π₁.
Choose Torus (g=1), Double Torus (g=2) or Sphere (g=0), then pick Wireframe, Shaded or Polygon Net view. Drag the canvas to rotate manually (auto-spin resumes when released), or use Major radius R and Minor radius r to reshape the torus tube, Rotation speed to change the auto-spin rate, and Mesh resolution to trade detail for performance.
A coffee mug and a donut are topologically identical — both have genus 1 — because one can be smoothly deformed into the other without cutting or gluing, which is exactly why a torus's fundamental group π₁ = ℤ × ℤ can never match a sphere's trivial one, no matter how you bend it.
Genus g counts the number of independent handles (or holes) a closed orientable surface has: a sphere has g=0, a torus (donut) has g=1, and a double torus has g=2. Switching the Surface buttons swaps between three different parametric meshes — sphere, single torus and a stitched double-torus — and the fact-grid immediately updates genus, Euler characteristic and fundamental group to match.
The Euler characteristic χ = V − E + F is a topological invariant of any triangulation of a surface, and for closed orientable surfaces it satisfies χ = 2 − 2g. Rather than counting vertices, edges and faces of the rendered mesh directly, this simulator looks up χ from the known formula for the currently selected genus (0, 0 →2, 1 →0, 2 →−2) and displays it in the Topological Invariants panel.
The double torus (genus 2) is approximated by generating two smaller toroidal tubes side by side and offsetting alternating halves of each ring, producing a figure-eight-like mesh rather than a mathematically exact connected sum of two tori with a handle fused between them. It is a visual approximation chosen for real-time rendering simplicity; its fundamental polygon (the octagon [a,b][c,d]) and Euler characteristic χ=−2 are, however, the exact genus-2 invariants.
Every closed orientable surface can be built by taking a flat polygon and gluing its edges together in pairs according to a word like aba⁻¹b⁻¹ (torus), aa⁻¹ (sphere) or [a,b][c,d] (double torus). This view draws that polygon with coloured, arrowed edges labelling exactly which sides get identified and in which direction — switching Surface changes both the polygon shape and its edge-word to match the selected genus.
Two surfaces are the same shape topologically (homeomorphic) only if one can be continuously stretched into the other without cutting or gluing, and a torus's hole makes that impossible for a sphere. This is captured algebraically by the fundamental group π₁ shown in the invariants panel: it is trivial for the sphere but ℤ × ℤ for the torus (one generator per independent loop around the hole), and homeomorphic surfaces must always share the same fundamental group.