Convex Hull
Andrew's monotone chain with cross-product turn tests
The tight boundary around a point set
The convex hull is the smallest convex polygon containing every input point. Imagine stretching a rubber band around the outermost points: when released, it touches the hull vertices and leaves all interior points enclosed.
Use cross products to keep only left turns
For points O, A, and B, the sign of (A-O) x (B-O) tells whether the path turns left or right. Andrew's algorithm sorts points by (x, y), scans left to right for the lower hull, then right to left for the upper hull. A non-left turn pops the middle point because it cannot belong to the convex boundary.
Sort the points by (x, y), then scan left to right to build the lower hull with cross-product turn tests.
Complexity and uses
Sorting costs O(n log n); each point enters and leaves each scan stack at most once, so both scans are linear. Convex hulls are a foundation for collision tests, farthest-point pairs, minimum enclosing shapes, and geometric preprocessing.