THE ORIENTATION left, right, or straight — the sign of the cross, made a verdict
The orientation predicate turns the cross product into a three-way answer: given three points, do they turn counter-clockwise (+1), clockwise (−1), or lie collinear (0)? It is the single most-used test in computational geometry — convex hulls, segment intersection, triangulation, and point location all branch on it. Its whole subtlety is robustness: on nearly-collinear points the sign must be exact, which is why serious libraries use exact-arithmetic predicates. Here, on clean integers, it is just the sign of one cross product — the verdict the rest of the batch appeals to.
THE TECHNIQUE sign of the cross — CCW(+1) / CW(−1) / collinear(0)
The demo runs the orientation test on three configurations — a left turn, a right turn, and three collinear points: live demo
HISTORY & CREDIT orientation predicate · robust predicates
“Turn direction is a matter of angles.” — it is the sign of one cross product; no angle is computed. cited
the test · sign( (b−a)×(c−a) ) — +1, −1, or 0. the uses · hull, intersection, triangulation, point location all branch on it. the catch · near-collinear points demand exact arithmetic — the robustness at the heart of the field.
The cross product read as a verdict — left, right, or straight, the branch every geometry algorithm takes. predicate
RECOMMEND FOR I-13 the three-way verdict, on the compiler
On the canonical compiler, the orientation test gives +1 (CCW), −1 (CW), and 0 (collinear):
$ i13 run cg_orientation.i13 # sign of the cross
RUN OK · 149 step(s) · peak stack 7 · call depth 2
ccw = 1 cw = -1 collinear = 0
all3 = 1
Recommend as a NULL — a validity/classification predicate. Orientation tests a configuration (which way three points turn) rather than generating a droppable invariant — a recognizer (B41), and its output is forall-pinned by the points (B39). No new axis. NULL — the workhorse branch of the whole field, reading the cross product of dart 486.