Testing whether a polygon is simple or complex

前端 未结 3 580
天涯浪人
天涯浪人 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:23

    There are sweep methods which can determine this much faster than a brute force approach. In addition, they can be used to break a non-simple polygon into multiple simple polygons.

    For details, see this article, in particular, this code to test for a simple polygon.

提交回复
热议问题