如何测试两个移动的2D方向包围盒的碰撞? [英] How do I test for collision of two moving 2d oriented bounding boxes?

查看:71
本文介绍了如何测试两个移动的2D方向包围盒的碰撞?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OBB具有位置(x,y),速度(x,y)和方向(Matrix)。给定定期更新,OBB必须相互碰撞,并返回被认为成功的部分分数。

The OBBs have a position(x,y), a velocity(x,y) and an orientation(Matrix). Given periodic updates, the OBBs must collide with each other, returning the fraction of the move that was deemed successful.

我已经看过GPWiki上的Polygon测试-< a href = http://gpwiki.org/index.php/Polygon_Collision rel = noreferrer> http://gpwiki.org/index.php/Polygon_Collision -但它不能解决移动对象的问题

I have looked at the Polygon test on the GPWiki - http://gpwiki.org/index.php/Polygon_Collision - but it does not account for moving objects or an object that is completely within an OBB.

《实时碰撞检测》一书在第4章:边界体积中涵盖了3D OBB,但是在3个维度上进行测试的方法是

The book Real Time Collision Detection covers 3D OBBs in Chapter 4: Bounding Volumes, but the method for testing in 3 dimensions is notably more complex than in 2D.

推荐答案

要测试2个定向边界框之间的碰撞检测,我将使用分离轴定理( SAT )。实际上,SAT可以用于任意两个凸形之间的碰撞检测。这种技术理解起来并不太复杂,并且具有合理的性能。
定理可以轻松地扩展到3D。

To test collision detections between 2 oriented bounding boxes, I'd use separating axis theorem (SAT). In fact SAT can be used for collision detection between any 2 convex shapes. This technique is not overly complex to understand and has a reasonable performance. The theorem can easily be extended to 3D.

编辑:

算法尝试确定是否可以在两个物体之间安装一个平面。如果存在这样的平面,则对象是分离的,并且不能相交。

The algorithm tries to determine is it is possible to fit a plane between two objects. If such a plane exists, then the object are separated, and cannot intersect.

要确定对象是否分离,只需将对象投影到对象上即可。 法线,并比较间隔并查看它们是否重叠。

To determine if the objects are separated, it is simply a matter of projecting the objects onto the normal of the plane, and comparing the intervals and see if they overlap.

因此,显然有无限多个平面可以容纳在两个分离的物体之间。但事实证明,您只需要测试少量飞机即可。

So, there is obviously an infinite number of planes that can fit between two separated objects. But it has been proved you only have to test a handful of planes.

可以证明,对于盒子来说,要测试的分离平面是法线等于两个盒子的轴的平面。因此,对于2个盒子,您总共只需要测试4个分离平面。在这4个平面中,一旦找到一个分隔框的分隔平面,便知道该框无法相交,并且返回无碰撞标志。

It can be shown that for boxes, the separation planes to be tested are the planes with normal equal to the axes of both boxes. So for 2 boxes, you only need to test 4 separation planes in total. Out of the 4 planes, once you found a separation plane that separates the boxes, then you know the box cannot intersect, and you return a no collision flag.

4架飞机无法将盒子分开,那么盒子必须是相交的,并且在那里发生碰撞。

If the 4 planes cannot separate the boxes, then the box must be intersection, and there you have a collision.

这篇关于如何测试两个移动的2D方向包围盒的碰撞?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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