线interesection横向 [英] Line interesection transversal

查看:308
本文介绍了线interesection横向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个线段。而线是随机的。我要检查是否有任何两个线之间任何交集。线可以连接或不连接。什么是对这个问题最好的算法。

I have several line segments . And lines are random. I have to check if there any intersection between any two line. Lines may be connected or not. What would be best algorithm for this problem.

code例子很多AP preciated。

Code Example is much appreciated.

编辑:线段

推荐答案

假设你正在谈论的线段这里(否则,只比较直线的斜率:如果他们有不平等的山坡上,它们相交)。

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

要了解一个[单一]交汇存在于一组2个或更多的线段,可以使用Shamos - 霍伊算法。

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

要查找的所有的一组2个或更多的线段,可以使用宾利奥特曼算法。交点

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.

这篇关于线interesection横向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆