如何检查多边形是否与自身相交? [英] How to check if the polygon is not intersected itself?

查看:241
本文介绍了如何检查多边形是否与自身相交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想检查多边形是否与自身相交,如何使用C ++或C#执行此操作?谢谢。

I want to check if the polygon is not intersected itself, how to do this with C++ or C#? Thanks.

推荐答案

如果你的意思是如何检测自相交的多边形?如沙漏:



If you mean "how do I detect a self-intersecting polygon?" such as an hourglass:

X------>X
 ^     /
  \   /
   \ /  
    \
   / \
  /   \
 v     \
X------>X

然后它是非平凡的。但是......存在几种算法,包括Bentley-Ottmann,如下所述: http://geomalgorithms.com/a09-_intersect -3.html [ ^ ]



您可以通过Google找到合适的C ++或C#实现 - 我没看过 - 但是编写自己的实现可能更容易,伪代码示例看起来合理简单易懂。



画错箭头......:doh:[/ edit]

Then it's non-trivial. But...several algorithms exist, including Bentley-Ottmann which is described here: http://geomalgorithms.com/a09-_intersect-3.html[^]

You may be able to find a suitable C++ or C# implementation via Google - I haven't looked - but it might be easier to write your own, the pseudocode examples look reasonably simple to follow.

[edit]Drew arrow head on wrong end... :doh: [/edit]


这篇关于如何检查多边形是否与自身相交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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