Definition · The orientation determinantFor points a, b, c in the plane, orient(a, b, c) is (bx − ax)(cy − ay) − (by − ay)(cx − ax). Its sign is 1 when the path a → b → c turns left (counter-clockwise), −1 when it turns right, and 0 when the three points lie on one line. All three of a, b, c are ordered arguments: swapping any two negates the determinant.
Two properties are worth having in hand before anything else. Negating on a swap means orient(a, b, c) = −orient(b, a, c), so “left of the line through a and b” and “right of the line through b and a” are the same statement. And the determinant depends only on the DIFFERENCES b − a and c − a, so translating all three points by the same vector changes nothing at all.
Theorem · The magnitude is twice the areaFor any three points, |orient(a, b, c)| equals twice the area of the triangle a b c. In particular the determinant is zero exactly when the triangle is degenerate, which is exactly when the three points are collinear.
Translate so that a is the origin; the determinant is unchanged and so is the area. Write u = b − a and v = c − a. The parallelogram spanned by u and v has area |u| |v| sin θ, where θ is the angle from u to v, and the triangle is half of it.
Now |u| |v| sin θ is exactly ux·vy − uy·vx up to sign: expand |u| |v| sin(β − α) with u = |u|(cos α, sin α) and v = |v|(cos β, sin β) and the angle-difference identity gives |u| |v| (sin β cos α − cos β sin α), which is ux·vy − uy·vx. The sign of sin θ is positive when v is counter-clockwise from u and negative when it is clockwise, which is the sign claim, and the area is half the absolute value, which is the magnitude claim.
□
So a determinant of 1 — the smallest nonzero value an integer determinant can have — is a triangle of area one half. The lab's (0, 0), (7, 3), (5, 2) example is exactly that: the determinant is −1, the three points are very nearly on a line, and they are definitively not. There is no room between “area one half” and “area zero” for an integer to be uncertain about.
Example · The same number by three different productsThe lab's opening points are (0, 0), (4, 0), (2, 3). The 2×2 route computes (4 − 0)(3 − 0) − (0 − 0)(2 − 0) = 12. The 3×3 route expands the determinant of the matrix whose rows are (0, 0, 1), (4, 0, 1), (2, 3, 1) by cofactors along the last column, giving 0·(0 − 3) − 0·(4 − 2) + (4·3 − 2·0) = 12. The double route runs the first expression in ordinary floating point and also reports 12. Three routes, one number, and the lab prints all three side by side.
Why bother with the second route at all, when it is algebraically the same determinant? Because it is not the same ARITHMETIC. The 2×2 form multiplies differences of coordinates; the 3×3 form multiplies the coordinates themselves. A transposed subscript in either one produces a number that looks entirely reasonable, and the only thing that catches it is another route that would have to be wrong in precisely the same way. The lab flags a disagreement in red and declines to say which side is right.
The sign answers four questions, and they are the same question
Is c to the left of the directed line a → b? That is orient(a, b, c) > 0. Do the segments p₁p₂ and q₁q₂ cross properly? That is four such tests with opposite signs in pairs. Is the polygon v₁ … vₙ wound counter-clockwise? That is the sum of n such determinants being positive. Did the last point pushed onto a hull stack make a non-left turn, so the one below it is not a corner after all? Same test again.
Every page on this course is one of those four, which is why it is worth spending a lesson on a single arithmetic expression. Get the sign wrong once and the hull loses a vertex, the segment test answers about the wrong pair, and the polygon reports the wrong orientation — each of them silently, each of them returning a well-formed answer to a question it was asked correctly.
Why the magnitude is kept as an integer even when it is thrown away
The lab prints the determinant, not just its sign, and the polygon page prints twice the area rather than the area. Doubling is what keeps it an integer: a lattice polygon's area can be a half, and a half is not representable as an integer, but twice it always is. Halving is left to the very end, and the result is printed as an exact fraction rather than as a decimal close to it.
That habit — postpone the division, keep the integer — is the whole of exactness in this course. Distances are kept squared for the same reason, since √2 is not a number this library can write down exactly and 2 is. Comparing squared distances orders pairs exactly as comparing distances does, so nothing is lost by never taking the root.