Geometric Algorithms
Nievergelt & Hinrichs · Ch. 8 · Algorithms and Data Structures
Convex hull wraps a point set in the smallest convex polygon. Graham scan does it in O(n log n). Line intersection, closest pair, and Voronoi diagrams extend these ideas to richer geometric problems.
Cross product orientation test
The foundation of computational geometry. Given three points P, Q, R: the cross product (Q-P) x (R-P) tells you whether R is left of, right of, or on the line PQ. Positive = left turn, negative = right turn, zero = collinear.
Scheme
Graham scan
Sort points by polar angle around the lowest point. Walk through the sorted points, keeping only left turns. O(n log n) for the sort, O(n) for the scan.
Scheme
Neighbors
Cross-references
- ∫ Calculus Ch.10 — vectors: the linear algebra behind cross products and projections
june.kim/power-diagrams-ad-auctions — Voronoi diagrams with weighted sites partition embedding space for ad targeting
june.kim/keywords-are-tiny-circles — keywords as degenerate Voronoi cells in continuous space