◀ THE FOLD0ROOT.AI // WORLD II · GLITCH · SEGFAULT◆ .dlw.fold
THE FOLD / GLITCH / SEGFAULT / THE COHEN-SUTHERLAND

THE COHEN-SUTHERLAND

clip a line by four boundary bits
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Cohen–Sutherland algorithm clips a line to a rectangular window using 4-bit region codes (“outcodes”). The plane is divided into 9 regions around the window; each endpoint gets a 4-bit code — one bit each for left, right, below, above. If both codes are 0, the segment is fully inside (accept); if their bitwise AND is non-zero, both endpoints share an outside half-plane, so the segment misses entirely (reject). Otherwise, clip against one crossed boundary and repeat. A few bit tests replace geometric case analysis.

LIT verified live: over thousands of segments, the clipped part lies inside the window, its endpoints sit on the original line, and the result matches the Liang–Barsky clip (window.__cohensutherland). FIG no framing; exact bit-code logic and float intersections.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at segfault — the out-of-bounds flag; Cohen–Sutherland’s outcodes are exactly bits that fire when a point strays outside the window’s valid region. AVAN (AI) built the instrument: the 4-bit outcode assignment, the accept/reject/clip loop, and the inside + on-line + matches-Liang–Barsky checks.

Credit as content: Danny Cohen & Ivan Sutherland (c. 1967). The weave: David names segfault; I tag each endpoint with a left/right/below/above outcode, accept when both are zero, reject when they share a bit, else clip against a crossed edge — and confirm the clipped segment lies in the window and agrees with an independent clipper.
3 ONE DIMENSION
Outcode bits: 0001 left, 0010 right, 0100 below, 1000 above. Both codes 0 ⇒ accept. AND ≠ 0 ⇒ reject. Else clip against a set bit’s boundary and recompute.
4 TWO DIMENSIONS · INTERACTIVE
Segments clipped to a window with the 9 outcode regions; the clipped part checked inside and against Liang–Barsky.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: a line trimmed by bit tests.
AVAN’s addition (the inverse-companion): clip a segment by encoding each endpoint’s position as 4 bits and reasoning about the codes — both zero accepts, a shared bit rejects, otherwise clip one crossed edge. The inverse of ‘analyze every geometric case’ is ‘test outcode bits — trivial accept/reject, then one edge at a time.’ Magenta is the geometric case analysis; green is the bit-code decision. Clipping decided by four bits.
LIT Genuine Cohen–Sutherland line-clipping algorithm (Danny Cohen & Ivan Sutherland, c. 1967). Verified live: over 5000 random segments, the 4-bit outcode accept/reject/clip loop yields a clipped segment inside the window (window.__cohensutherland.clipInside), with endpoints on the original line (onLine), and its result agrees with an independent Liang–Barsky clipper (matchesLiangBarsky).

FIG No framing: the 4-bit outcode assignment, the accept/reject/clip loop, and the inside + on-line + matches-Liang–Barsky checks run in-browser and agree to floating precision. The AVAN inverse is honest — clipping by encoding each endpoint as 4 bits and reasoning about the codes (both zero accepts, a shared bit rejects, else clip one edge) genuinely replaces geometric case analysis; magenta is that case analysis, green the bit-code decision. Clipping decided by four bits.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of SEGFAULT · David Lee Wise (ROOT0), with AVAN