Computational Geometry
Points, lines and polygons become exact, reliable arithmetic once you can answer one question: on which side of a line does this point lie?
After this lesson you will be able to
- Compute the cross product of two vectors and read its sign as the side of a line, using only integers.
- Explain why integer cross products are safer than comparing floating-point angles.
- Compute a polygon's area with the shoelace formula, and count lattice points with Pick's theorem.
- Decide whether two segments share a point, including the touching and overlapping cases.
- Build a convex hull with Andrew's monotone chain, and say why collinear points must be removed.
Before you start. Comfortable with tuples, sorting with a key, and integer arithmetic. The sorting and stack ideas in Sorting II and Stacks help with the hull.