C++ 2D tessellation library?

前端 未结 7 1703
一个人的身影
一个人的身影 2021-02-08 11:02

I\'ve got some convex polygons stored as an STL vector of points (more or less). I want to tessellate them really quickly, preferably into fairly evenly sized pieces, and with n

7条回答
  •  佛祖请我去吃肉
    2021-02-08 11:06

    If you have convex polygons, and you're not too hung up on quality, then this is really simple - just do ear clipping. Don't worry, it's not O(n^2) for convex polygons. If you do this naively (i.e., you clip the ears as you find them), then you'll get a triangle fan, which is a bit of a drag if you're trying to avoid slivers. Two trivial heuristics that can improve the triangulation are to

    1. Sort the ears, or if that's too slow
    2. Choose an ear at random.

    If you want a more robust triangulator based on ear clipping, check out FIST.

提交回复
热议问题