Testing whether a polygon is simple or complex

前端 未结 3 584
天涯浪人
天涯浪人 2020-12-13 15:45

For a polygon defined as a sequence of (x,y) points, how can I detect whether it is complex or not? A complex polygon has intersections with itself, as shown:

3条回答
  •  余生分开走
    2020-12-13 16:14

    In fact, this can be done in linear time use Chazelle's triangulation algorithm. It either triangulates the polygon or find out the polygon is not simple.

提交回复
热议问题