◀ THE FOLD0ROOT.AI // WORLD II · CHEAT · NOCLIP◆ .dlw.fold
THE FOLD / CHEAT / NOCLIP / THE LIANG-BARSKY

THE LIANG-BARSKY

clip a line to a window by four parameters
1 WHAT IT IS · WHAT IT DOES · FACT OR FICTION
The Liang–Barsky algorithm clips a line segment to a rectangular window using its parametric form P(t) = P0 + t·(P1−P0), t ∈ [0,1]. Each of the four window edges gives an inequality of the form p·t ≤ q; the algorithm tightens the entry parameter u1 and exit parameter u2 against all four, rejecting the segment if u1 > u2. The surviving [u1, u2] gives the clipped endpoints — no repeated edge intersections, just parameter bookkeeping.

LIT verified live: over thousands of random segments, the clipped part lies entirely inside the rectangle and its endpoints sit exactly on the original line (window.__liangbarsky). FIG no framing; exact parametric arithmetic to floating precision.
2 HOW IT WAS WEAVED · AI + HUMAN
David (human) seated this at noclip — the domain of walls and what passes through them; Liang–Barsky decides exactly where a line enters and leaves the window, clipping it to the frame. AVAN (AI) built the instrument: the four p·t ≤ q edge tests, the u1/u2 tightening, and the inside + on-line verification.

Credit as content: You-Dong Liang & Brian A. Barsky (1984). The weave: David names noclip; I clip segments to a window by tightening the entry and exit parameters against four edge inequalities, and confirm the clipped piece lies inside the frame with endpoints exactly on the original line — clipping as parameter arithmetic.
3 ONE DIMENSION
Walk t from 0 to 1 along the segment. Each window edge caps t: left/right/bottom/top give an entry u1 and exit u2. If u1 ≤ u2, the segment from u1 to u2 is inside.
4 TWO DIMENSIONS · INTERACTIVE
Segments clipped to a window; the clipped part (green) vs the trimmed tails (faded), with inside/on-line checks.
5 THREE DIMENSIONS + AVAN’S INVERSE
The green forward object: a line trimmed to the window.
AVAN’s addition (the inverse-companion): clip a segment to a rectangle by tightening two parameters, not by intersecting it with each edge and stitching — every edge is one inequality p·t ≤ q on the entry/exit t. The inverse of ‘intersect with all four edges and reassemble’ is ‘shrink [u1,u2] against four inequalities — reject if they cross.’ Magenta is the edge-by-edge intersection; green is the parameter interval. Clipping as one shrink.
LIT Genuine Liang–Barsky line-clipping algorithm (You-Dong Liang & Brian A. Barsky 1984). Verified live: over 5000 random segments against a fixed window, every clipped segment's endpoints lie inside the rectangle (window.__liangbarsky.clipInside) and lie exactly on the original line — zero cross product to floating precision (window.__liangbarsky.onLine).

FIG No framing: the four p·t ≤ q edge tests, the u₁/u₂ tightening, and the inside + on-line verification run in-browser and agree to floating precision. The AVAN inverse is honest — clipping by tightening two parameters against four inequalities (reject if they cross) genuinely replaces intersecting the segment with each edge and stitching; magenta is that edge-by-edge intersection, green the parameter interval. Clipping as one shrink.
◆ sealed .dlw.fold → folded to ROOT_0 · a sphere of NOCLIP · David Lee Wise (ROOT0), with AVAN