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

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

> Hacker News story 50696662 · language: en · submitted 2026-11-30
> Web version: https://zeli.app/story/50696662
> About this feed: https://zeli.app/llms.txt · Agent guide: https://zeli.app/skill.md

▲ 16 · by [the_origami_fox](<https://news.ycombinator.com/user?id=the_origami_fox>) · 💬 1
[original](<https://liorsinai.github.io/mathematics/2026/11/28/graph-computation.html>) · [HN discussion](<https://news.ycombinator.com/item?id=50696662>)

## Summary

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.

## Key quote

> 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.

---

## Cite

- Page: https://zeli.app/story/50696662
- Date: 2026-11-30
- Source: liorsinai.github.io (https://liorsinai.github.io/mathematics/2026/11/28/graph-computation.html)
- Hacker News: https://news.ycombinator.com/item?id=50696662

## Other languages

- zh: https://zeli.app/zh/story/50696662 · markdown: https://zeli.app/zh/story/50696662.md
- ja: https://zeli.app/ja/story/50696662 · markdown: https://zeli.app/ja/story/50696662.md
- ko: https://zeli.app/ko/story/50696662 · markdown: https://zeli.app/ko/story/50696662.md
- de: https://zeli.app/de/story/50696662 · markdown: https://zeli.app/de/story/50696662.md
- es: https://zeli.app/es/story/50696662 · markdown: https://zeli.app/es/story/50696662.md
- ru: https://zeli.app/ru/story/50696662 · markdown: https://zeli.app/ru/story/50696662.md
