Signed area is an oriented area: its magnitude measures the parallelogram spanned by two vectors, while its sign records their ordering. For vectors a = (a1, a2) and b = (b1, b2), compute a1b2 − a2b1. Counterclockwise ordering gives a positive result; clockwise ordering gives a negative result. section 9.3.3 section 9.5.2
Signed area supports several practical geometric decisions:
- Classify which side of an oriented edge contains a point by inspecting the sign. section 9.3.3
- Test triangle containment by requiring consistent side-of-edge signs for all three edges. section 9.3.3
- Convert signed area into signed distance from a point to a line by dividing by the base segment’s length. section 10.1.4
A compact implementation
The core operation can be written as `box2d(x1, y1, x2, y2) = x1*y2 - x2*y1`. For a point and an oriented line segment, compute `box2d(x-x1, y-y1, x2-x1, y2-y1) / distance_p2p(x1, y1, x2, y2)` to obtain signed point-to-line distance. A rectangle’s signed distance function then uses the closest edge’s unsigned distance and restores its sign from that edge’s line. section 10.1.4
Visualize the sign changing as one vector crosses the other, making orientation easier to connect with the determinant formula. section 9.3.3
