This project generates 3D-printable STL models of surfaces from **catastrophe theory** — a branch of mathematics studying how small changes in parameters can cause sudden, discontinuous changes in a system's equilibrium state.
Two surfaces are being produced:
| Model | Catastrophe Type | Codimension | Potential |
Each surface is the **equilibrium manifold** — the set of all points where the system is in equilibrium. For a potential V(x), equilibria satisfy:
> dV/dx = 0
The 3D surface is swept over the control parameter space (a, b), with x (the state variable) as the third axis. Where the surface folds back on itself is the **bifurcation set** — the region where the system can catastrophically jump between states.
- **State space:** up to 5 real roots x at any given (c, d)
- **Characteristic feature:** nested "butterfly wing" fold structure — a self-intersecting bifurcation curve in the (c, d) plane enclosing a 5-root "pocket" (c∈[0,3], d≈0), surrounded by a 3-root wing region, with a single-root region outside
> **Why not vary (a, b) with c=d=0?** With c=d=0, the equilibrium equation factors as
> x²(6x³ + 4ax + 3b) = 0 — x=0 is always a double root and the remaining roots come
> from a cubic, which is structurally identical to the **cusp** catastrophe. The butterfly
> structure only appears when d ≠ 0 generically, which requires d (or an equivalent odd
> perturbation) to be varied as a control parameter.
> A cusp catastrophe script also exists and was the starting point for this project.
---
## How the Generator Works
1.**Root finding** — at each (a, b) grid point, all real roots of dV/dx = 0 are found using Newton-Raphson with dense initial seeding across the x range
2.**Branch tracking** — roots are sorted and matched by branch index across adjacent grid cells
3.**Mesh construction** — adjacent grid quads on the same branch are triangulated into a surface mesh
4.**Base slab** — a flat rectangular base is added so the model is self-supporting on a print bed
5.**ASCII STL output** — written as ASCII (not binary) for maximum compatibility with slicers and viewers