Give a computer graphics engine, a mesh generator, or a robot's path planner a simple polygon — any closed shape with straight sides and no self-crossings — and sooner or later it needs to break that polygon into triangles. Triangles are the atoms of computational geometry: easy to render, easy to reason about, easy to feed into physics and rendering pipelines.
Any simple polygon with vertices can always be triangulated into exactly triangles using only diagonals that stay inside the shape. The question is not whether it can be done — it's how fast.
The naive approach pokes around for a valid diagonal, cuts, and repeats, costing or worse. But if you first slice the polygon into pieces that are y-monotone — pieces where a vertical sweep never has to backtrack — each piece can be triangulated in a single linear pass with nothing more than a stack. That two-stage idea, sweep-to-split then stack-to-triangulate, is one of the cleanest results in computational geometry.
Comments
Loading comments...