Algorithm to find intersections between polylines

后端 未结 2 1785
滥情空心
滥情空心 2021-02-06 07:12

Bentley-Ottmann algorithm works for finding intersections of set of straight lines. But I have lot of polylines:

\"e

2条回答
  •  遇见更好的自我
    2021-02-06 07:41

    The sweep line algorithm has a nice theory but is hard to implement robustly. You need to treat vertical segments, and there might be cases where more than two line segments intersect in a single point (or even share a common line segment).

    I'd use an R-Tree to store bounding boxes of the line segments of the polyline and then use the R-Tree to find possibly intersecting elements. Only these need to be tested for intersection. The advantage is that you can use a separate R-Tree for each polyline and thus avoid detection of selfintersections, if needed.

    Consider using CGAL's exact predicates kernel to get reliable results.

提交回复
热议问题