# Martinez-Rueda算法：从线段到路径

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

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

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

## Summary

Martinez-Rueda算法是计算多边形布尔运算的利器，广泛应用于Inkscape和GIS系统。该算法输出的是线段集合，但实际应用中我们需要有序的路径。传统的“线段链式”算法在处理自相交多边形时容易出错，导致无法闭合的链。我最近在PolygonAlgorithms.jl包中引入了图面计算算法，彻底解决了这一问题。新算法能正确处理不规则多边形，并自动区分外轮廓和孔洞，确保输出方向一致且结果稳定。

## Key quote

> 图面计算算法不仅能处理不规则多边形，还能返回一致的轮廓方向，将所有外部轮廓设为逆时针，内部孔洞设为顺时针。

---

## Cite

- Page: https://zeli.app/zh/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

- en: https://zeli.app/story/50696662 · markdown: https://zeli.app/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
