Given a list of line segments, the easiest way to find the intersection points is to loop through the line segment list, check whether they are intersecting and record the intersection point if they do.
But the runtime of this method is O(n^2)
, which is very inefficient. Is there any other algorithm that could speed up this process?
The Bentley-Ottmann Algorithm may be what you are looking for.
来源:https://stackoverflow.com/questions/4125452/find-the-intersection-points-of-all-the-line-segments