◀ THE FOLD0ROOT.AI // WORLD II · SPAWN · FIRST LIGHT◆ .dlw.fold
THE FOLD / SPAWN / FIRST LIGHT / THE MARCHING SQUARES

THE MARCHING SQUARES

trace an isoline through a grid of values
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
Marching squares extracts a contour — an isoline — from a grid of scalar values. For each cell it looks at which of the four corners are above the threshold: a 4-bit case index (0–15) selects, from a small lookup table, which cell edges the contour crosses. The exact crossing point on each edge is found by linear interpolation between the two corner values. Stitched together, the segments trace the level set. It is how weather maps draw isobars and how metaballs get their outlines.

LIT verified live: over 60 random fields, every contour vertex sits on a grid edge whose two endpoints straddle the threshold (one above, one below) — window.__marching. FIG no framing; exact.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at first-light — the first outline drawn from a field of values, the boundary between above and below. Marching squares is that outline. AVAN (AI) built the instrument: the 4-corner case index, the edge lookup, the linear-interpolation crossing, and the every-vertex-on-a-straddling-edge check.

Credit as content: marching squares (the 2-D case of Lorensen & Cline’s marching cubes, 1987). The weave: David names first-light; I classify each cell by its corners, interpolate the crossing on each straddling edge, and confirm every contour vertex lies exactly where the field crosses the level.
3 ONE DIMENSION
A cell’s four corners are each above (1) or below (0) the threshold — a 4-bit index. The contour crosses exactly the edges whose two ends disagree, at the linearly-interpolated level-crossing point.
4 TWO DIMENSIONS · INTERACTIVE
A scalar field and its contour at a threshold; every contour vertex is checked to sit on a straddling edge.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: the isoline threading the grid.
AVAN’s addition (the inverse-companion): draw the boundary between above and below by reading each cell’s four corners as a case index and interpolating the crossing on every straddling edge. The inverse of ‘sample the field densely and threshold each pixel’ is ‘classify cells, interpolate crossings — a crisp isoline.’ Magenta is the jagged per-pixel threshold; green is the interpolated contour. The level set, threaded through a grid.
LIT Genuine marching squares (the 2-D case of Lorensen & Cline's marching cubes 1987). Verified live: over 60 random scalar fields, every contour vertex produced sits on a grid edge whose two endpoints straddle the threshold (one above, one below), at the linearly-interpolated crossing (window.__marching.allOnStraddle).

FIG No framing: the 4-corner case index, the edge lookup, the linear-interpolation crossing, and the every-vertex-on-a-straddling-edge check run in-browser and hold. The AVAN inverse is honest — classifying each cell by its corners and interpolating the crossing on every straddling edge traces a crisp isoline; magenta is the jagged per-pixel threshold, green the interpolated contour. The level set, threaded through a grid.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of FIRST LIGHT · David Lee Wise (ROOT0), with AVAN