
SurfZar Deep-Dive: Differential Geometry Probing (Gaussian & Mean Curvature), Implicit CSG & Watertight 3D Printing
Table of Contents (4 sections)▸
In our earlier articles on iSurfer and SurfZar, we explored how WebGL2 fragment shaders ray-trace implicit algebraic surfaces in real time.
However, a true mathematical laboratory needs more than visual rendering:
- Differential Geometry Inspection (
SurfacePointProbe.ts): When a mathematician or student clicks any point on a 3D surface, what is the exact Tangent Plane, Gaussian Curvature (), Mean Curvature (), and local surface classification (elliptic,hyperbolic,parabolic,planar, orsingularity)? - Constructive Solid Geometry (CSG) & Homotopy Morphing (
MeshExporter.ts): How do we combine two algebraic equations and via boolean operations, smooth organic blends, or continuous topological homotopies? - Watertight 3D Printing: How do you turn an infinitely thin mathematical zero-set clipped by a bounding sphere into a solid, manifold STL/OBJ/GLB sculpture that a 3D printer slicer (Bambu Studio, PrusaSlicer) can actually print?
Here is how those three subsystems work under the hood in SurfZar.
Click to zoomSurfZar Studio — Inspecting and morphing high-genus algebraic manifolds
1. Computing Gaussian () & Mean () Curvature Without Surface Parameterization#
In classical differential geometry textbooks, curvature is usually taught using a parametric surface patch via the First and Second Fundamental Forms.
But for an implicit algebraic surface (such as the Barth Sextic or Gyroid), no global parameterization exists!
In src/lib/SurfacePointProbe.ts (computeDifferentialGeometryAtPoint), when a user clicks on the 3D canvas, we cast a picking ray , refine the intersection point via Newton-Bisection, and compute the gradient vector and the symmetric Hessian matrix using central finite-difference stencils:
The Implicit Curvature Determinants#
Using the classical adjugate Hessian / bordered Hessian formulas for implicit surfaces, we compute the Gaussian Curvature and Mean Curvature directly from and in :
From , SurfacePointProbe.ts automatically classifies the local differential geometry at the probed point:
| Condition | Classification | Geometric Meaning |
|---|---|---|
singularity | Conical double point (), cusp, or self-intersection line | |
| $ | K | < \varepsilon \text{ and } |
| $ | K | < \varepsilon \text{ and } |
elliptic | Dome or bowl ( have the same sign) | |
hyperbolic | Saddle point ( have opposite signs, e.g., minimal surfaces where ) |
And from the unit normal , it formats the exact Tangent Plane equation at :
2. Implicit CSG Booleans, Smooth Blending & Homotopy Continuation#
Because implicit surfaces represent geometry as scalar fields , buildCompositeEvalFn (src/lib/MeshExporter.ts) can combine a primary equation and secondary equation into a composite scalar field both in the GLSL shader and in the mesh exporter:
- Exact Ricci CSG Booleans:
- Union ():
- Intersection ():
- Difference ():
- -Continuous Smooth Minimum (
smooth_blend): To create organic fillets where two algebraic surfaces meet, we apply polynomial smooth-minimum blending with radius : - Homotopy Continuation (): Enabling Homotopy mode constructs the convex linear combination: Animating from lets users watch a sphere () continuously deform its genus and bifurcate into the 65-node Barth Sextic!
3. Turning Zero-Thickness Surfaces into Watertight 3D Prints (shellThickness)#
Here is a classic trap when exporting an implicit surface for 3D printing:
- A surface like the Gyroid () or Steiner's Roman Surface is an open, infinitely thin 2D sheet clipped by a bounding sphere or cube.
- If you run Marching Cubes directly on inside , the resulting mesh has zero thickness and open boundary edges where the surface hits the bounding box walls. Every 3D printer slicer rejects open, non-manifold sheets!
To make any algebraic or transcendental surface immediately 3D-printable (src/lib/MeshExporter.ts), we implemented Implicit Offset Shell Thickening (shellThickness ) combined with Boundary Envelope Capping:
- Taking offsets the zero-isosurface into two parallel sheets at and , enclosing a solid volume of thickness .
- Intersecting that shell () with the bounding volume automatically caps every boundary cross-section, guaranteeing that Marching Cubes extracts a 100% closed, watertight, orientable 2-manifold ready to export as binary STL, vertex-colored OBJ, or GLB (
GLTFExporter).