Line intersection transversal

為{幸葍}努か 提交于 2019-12-08 11:02:06

问题


I have several random line segments. I have to check if there is any intersection between any two line segments. Lines may be connected or not. What would be a good algorithm for this problem?


回答1:


Assuming you're talking about line segments here (otherwise, simply compare the slopes of the lines: if they have unequal slopes, they intersect).

To find out if a [single] intersection exists in a set of 2 or more line segments, you can use the Shamos-Hoey algorithm.

To find all intersections in a set of 2 or more line segments, you can use the Bentley-Ottmann algorithm.

Implementation of the two, and other "sweep-line" based algorithms, are abundantly available on the internet.



来源:https://stackoverflow.com/questions/11628798/line-intersection-transversal

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!