Open-Source Computational Geometry & Fabrication Reference

Stained Glass SVG Math: Half-Edge Seams, Copper Foil Kerf & Fracture Checks

Zero-dependency browser & Node.js equations that bridge digital vector tracing with physical stained glass fabrication: topological seam deduplication for Cricut stencils, miter-limited foil/came kerf offsets, concave score-snap diagnostics, and 96-DPI multi-page registration.

Interactive Kerf, Concavity & 96-DPI Print Verifier

Powered directly by glass-geometry.mjs in your browser. Toggle glass piece geometry and foil/came blade presets to inspect vertex bisector insets, reflex fracture warnings, and tiled home-printer pagination.

Per-Piece Inset 0.45 mm (0.0177")
Zero-Gap Panel Creep +11.7 mm (+0.461")
Max Interior Angle 270° (Throat 24 mm)
96-DPI ViewBox & Tiles 1536×1920 • 9 pages

1. Topological Shared Half-Edge Extraction (Stopping Cricut Double-Cuts)

Standard raster-to-SVG tracers contour each color region independently. Every interior solder line between region A and region B is emitted twice: once clockwise for A and once counter-clockwise for B. On a Cricut Maker or laser cutter slicing adhesive vinyl stencils, double-stroking shared edges shreds narrow 0.9 mm stencil bridges.

Piece A Piece B
Naive Region Trace: 12 directed edges — center seam cut twice by plotter blade.
Loop A Loop B
Half-Edge Graph: 1 single-stroke interior seam locked at degree-3 junctions.
// Canonical undirected edge key collapses opposite directed half-edges (u -> v) & (v -> u)
const forward = sx < ex || (sx === ex && sy < ey);
const edgeKey = forward ? `${sx},${sy}|${ex},${ey}` : `${ex},${ey}|${sx},${sy}`;

// Lock topological junctions (degree !== 2) before Ramer-Douglas-Peucker simplification
// so 3-way and 4-way solder joints remain 100% watertight without T-cracks.

2. Copper Foil & Lead Came Kerf Polygon Offset Math

Wrapping glass edges in 7/32" copper foil tape plus capillary solder tinning adds roughly 0.90 mm (0.036") per joint. Cutting 14 pieces across a window panel from uncompensated zero-gap lines pushes the soldered panel 13 × 0.90 mm = 11.7 mm (0.461" — nearly half an inch) past its wood frame.

Construction Technique Total Seam Kerf Per-Piece Inward Inset Physical Shop Equivalent
Standard Copper Foil (7/32") 0.90 mm (0.0354") 0.45 mm (0.0177") 3-bladed foil pattern shears (0.036" center strip)
Heavy Foil / Wavy Architectural 1.20 mm (0.0472") 0.60 mm (0.0236") 1/4" wide heavy foil + textured glass relief
Traditional Lead Came 2.00 mm (0.0787") 1.00 mm (0.0394") 5/64" H-came & U-came heart thickness
Glass-on-Glass Mosaic 2.40 mm (0.0945") 1.20 mm (0.0472") 3/32" sanded grout joint clearance
// Winding-invariant inward normal via signed shoelace orientation s = sign(Area_signed)
// Works identically in SVG y-down (CW > 0) and Cartesian y-up (CCW > 0):
const nx = orientation * -ty;
const ny = orientation * tx;

// Offset edge intersection Q0 + u*t0 = Q1 + v*t1 with miter-limit clamp (L_max = 3.0 * d)
const denom = prev.tx * curr.ty - prev.ty * curr.tx;
const u = ((q1x - q0x) * curr.ty - (q1y - q0y) * curr.tx) / denom;

3. Score-and-Snap Concavity & Narrow-Waist Fracture Physics

Unlike laser-cut acrylic or CNC plywood, hand-scored stained glass fractures along continuous tension lines. When an inside polygon vertex has a reflex interior angle exceeding 195°—or narrows to a high-aspect waist—running pliers propagate the crack straight across the piece rather than turning the corner.

// Winding-invariant interior angle in (0°, 360°) at vertex P_i:
const turn = orientation * (bx * ay - by * ax);
const dot  = ax * bx + ay * by;
const angleDeg = ((Math.atan2(turn, dot) + 2 * Math.PI) % (2 * Math.PI)) * (180 / Math.PI);

// Classification:
//   ≤ 195° : Safe carbide hand score + running/grozing pliers
// 195°–225° : Score shallow crescent relief arcs + grind flush on diamond bit
//   > 225° : Split with a structural solder seam or cut on a diamond ring saw

4. 96-DPI True-Scale SVGs, Multi-Page Tiling & Suncatcher Hanging Seams

Omitting physical units on an <svg> root leaves desktop printers and vinyl cutters guessing between 72 DPI, 90 DPI, and 96 DPI. Locking root dimensions in inches while scaling viewBox at 96 CSS px/in guarantees exact 1:1 output across Cricut Design Space, LightBurn, and browser print engines:

<svg xmlns="http://www.w3.org/2000/svg" width="16in" height="20in" viewBox="0 0 1536 1920">

// US Letter (8.5x11", 0.5" margin => 7.5x10" printable, 0.375" glue overlap => 7.125x9.625" step)
// Suncatcher structural rule: NEVER solder jump rings solely to outer edge foil —
// anchor wire tails into upper interior solder seams straddling horizontal center of mass.

5. Interactive Browser Implementations

All five production web tools below implement these client-side geometry pipelines directly in the browser with zero account signup and instant true-scale SVG / PDF export:

6. Run the Open-Source CLI & Unit Test Suite

Clone github.com/kaiyilu/stained-glass-svg-math and run the zero-dependency Node.js test suite (Node 18+):

git clone https://github.com/kaiyilu/stained-glass-svg-math.git
cd stained-glass-svg-math
node --test
node glass-geometry.mjs