方法来检测矩形和多边形之间的相交? [英] Method to detect intersection between a rectangle and a polygon?

查看:641
本文介绍了方法来检测矩形和多边形之间的相交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是检测红色矩形是否黑多边形重叠的最佳方法?请参阅本图片:

What is the best method to detect whether the red rectangle overlaps the black polygon? Please refer to this image:

推荐答案

如果您的多边形是不是凸,您可以使用的镶嵌细分成凸子部分。既然你正在寻找方法来检测可能的碰撞,我想你可以看看的的 GJK算法了。即使你并不需要的东西,功能强大(它提供了两个凸形状和相关证人点之间的最小距离信息),它可能被证明是有用的,如果你决定要处理更多不同的凸形。

If your polygon is not convex, you can use tessellation to subdivide it into convex subparts. Since you are looking for methods to detect a possible collision, I think you could have a look at the GJK algorithm too. Even if you do not need something that powerful (it provides information on the minimum distance between two convex shapes and the associated witness points), it could prove to be useful if you decide to handle more different convex shapes.

克里斯特埃里克森打了一个漂亮的简报presentation 如果您想了解更多关于这算法。您还可以看看他的书,实时碰撞检测的,这既是全面和方便的人发现碰撞检测算法。

Christer Ericson made a nice Powerpoint presentation if you want to know more about this algorithm. You could also take a look at his book, Real-Time Collision Detection, which is both complete and accessible for anyone discovering collision detection algorithms.

这篇关于方法来检测矩形和多边形之间的相交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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