Martinez-Rueda algorithm gets a graph-faces upgrade to handle improper polygons

Notes on the Martinez-Rueda Polygon Clipping Algorithm: Segments to Paths

Martinez-Rueda algorithm gets a graph-faces upgrade to handle improper polygons

The Martinez-Rueda algorithm computes boolean operations on polygons by annotating segments during a line sweep, but converting the resulting segments into ordered paths is tricky—especially for self-intersecting or improper polygons. The author replaced a fragile segment-chaining approach with graph face computation, which is linear in the number of edges. This method handles improper polygons, returns consistent polygon orientations, and offers two modes: SPLIT_FACES and MERGE_FACES. The implementation is available in the PolygonAlgorithms.jl Julia package.

The most important insight is that the directed graph has no information on fill. You cannot tell whether a face is a hole or not from the graph.

More from this day

2026-12-01