Simple 2d polygon triangulation

前端 未结 4 2076
故里飘歌
故里飘歌 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 10:13

    You are doing a version of "ear clipping" approach to triangulation, see: http://en.wikipedia.org/wiki/Polygon_triangulation

    Your algorithm fails if another polygon vertex (say from the other side of the polygon) ends up inside the triangle 'ear' you form. Consider this example:

    enter image description here

    Your algorithm will choose A first, and make a triangle with the two adjacent edges (connected with the dashed line). But this triangle includes another vertex (B) and is clearly incorrect.

    The generalized ear clipping approach depends on finding ears you can clip off that do not have any included vertices.

提交回复
热议问题