THE CROSS PRODUCT one multiply-subtract that runs all of plane geometry
Almost every question in 2D geometry — which way does this turn, what is this area, do these cross, is this point inside — reduces to one number: the 2D cross product(b−a) × (c−a) = (bx−ax)(cy−ay) − (by−ay)(cx−ax). It is the signed area of the parallelogram on the two vectors, and its sign tells you the turn direction. No trigonometry, no square roots — two multiplies and a subtract. Everything else in this batch is a way of reading this one primitive. For A(0,0), B(4,0), C(0,3) it is +12: a left (counter-clockwise) turn.
THE TECHNIQUE (bx−ax)(cy−ay) − (by−ay)(cx−ax) — signed parallelogram area
The demo computes the cross product of three points — a positive value meaning a counter-clockwise turn: live demo
HISTORY & CREDIT the 2D cross / perp-dot product
“Geometry needs angles and distances.” — turns, areas, and containment all fall out of one signed multiply-subtract. cited
the value · (b−a)×(c−a) — twice the signed area of triangle abc. the sign · + left turn, − right turn, 0 collinear (dart 487). the reach · area, hull, intersection, point-in-triangle — every dart here reads this one number.
A single multiply-subtract that answers which-way, how-big, and inside-or-out — the atom of plane geometry. primitive
RECOMMEND FOR I-13 the signed area, on the compiler
On the canonical compiler, the cross product of A(0,0), B(4,0), C(0,3) is +12 — a counter-clockwise turn:
$ i13 run cg_crossproduct.i13 # (b-a) x (c-a)
RUN OK · 34 step(s) · peak stack 7 · call depth 1
z = 12 -- twice the area of the triangle (area 6)
ccw = 1 -- positive: a left turn
Recommend as a keeper shot, then NULL. The cross product is astonishing in reach — one primitive that the whole batch reduces to — which tempts a “universal-primitive” axis. But it computes a pinned value (the signed area): every correct implementation returns 12, so there is no property two same-function mechanisms can differ on (B39). It generates a number, but that number is coextensive with the geometry, not a droppable companion channel. NULL by B39 — and the honest marvel of the batch: how much falls out of so little.