Cutting Shapes to Fit
Polygon clipping answers a simple question: what remains when you cut one polygon with another? This operation is essential every time your GPU renders a 3D scene (viewport clipping), every time a GIS computes land use overlap, and every time a CAD system performs a Boolean intersection. The Sutherland-Hodgman algorithm, published in 1974, remains the workhorse implementation.
Sutherland-Hodgman Algorithm
The algorithm processes the clip window one edge at a time. For each clip edge, it walks the subject polygon's vertices and classifies each as inside or outside. Four cases arise: inside-to-inside (keep vertex), inside-to-outside (output intersection), outside-to-outside (skip), outside-to-inside (output intersection then vertex). After all clip edges are processed, the surviving vertices form the clipped polygon.
Handling Complexity
When polygons are concave, clipping can produce multiple disconnected regions. Sutherland-Hodgman generates a single (possibly self-intersecting) polygon in this case. The Weiler-Atherton algorithm (1977) correctly handles concavity by tracing intersections around both polygons, producing separate output components. This simulator uses the simpler Sutherland-Hodgman approach with convex clip windows.
From Graphics to Geography
Every pixel on your screen has been polygon-clipped — the GPU's rasterizer clips triangles against the viewport frustum before shading. In GIS, polygon clipping overlays thematic maps: intersecting forest coverage with administrative boundaries reveals forest area per district. And in computational fabrication, clipping polygons against tool paths determines material removal — connecting abstract geometry to physical manufacturing.