Simple 2d polygon triangulation

前端 未结 4 2077
故里飘歌
故里飘歌 2020-12-28 09:26

Trying to triangulate a set of simple 2d polygons, I\'ve come up with this algorithm:

  • 1) For each vertex in the polygon, compute the angle bet
4条回答
  •  抹茶落季
    2020-12-28 09:59

    Simple Convex Polygons are O(n)

    This is when you want to handle simple polygons like rectangles, pentagons, hexagons and so on. Here you just take a starting point and connect it to all other vertices. This algorithm is trivial and what I really wanted was a more general solution that could handle concave and polygons with holes.

    In order to deal with more complex polygons like the one Payne provided...

    complex polygons

    Arbitrary Polygon to Triangle in O(n log n)

    While there are algorithms that run faster, the faster algorithms become very complicated. Kirkpatrick et al. found an algorithm to run in O(n log log n) and Chazelle did it in O(n). However, the easiest thing to implement is probably the Seidel algorithm that runs in O(n log n).

    The algorithm is a 3-step process

    1. Decompose the polygon into trapezoids
    2. Decompose the trapezoids into monotone polygons
    3. Decompose the monotone polygons into triangles

    C source

    If you're interested in C source it can be obtained from University of North Carolina at Chapel Hill. In general the code quality is good, handles holes, but will probably need to be massaged to your needs.

提交回复
热议问题