框球碰撞 [英] Box to Sphere Collision

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

问题描述

我需要检查,如果一个框碰撞与一个球体。我已经用X,Y,Z,宽度,高度,深度限定的BoundingBox的类。我还与X,Y,Z,半径限定一BoundingSphere所类。如何我检查,看看他们是否相交?

I need to check if a box is colliding with a sphere. I have a BoundingBox class defined with x, y, z, width, height, depth. I also have a BoundingSphere class defined with x, y, z, radius. How to I check to see if they intersect?

推荐答案

要检查的第一件事是,如果boundingBox的为BoundingSphere所相交。这样做的原因是,它是一个非常简单的方法来排除所涉及的更复杂的数学运算。

The first thing to check is if the BoundingBox for the BoundingSphere intersects. The reason for this is that it's a very simple way to rule out the more complicated math involved.

下一步将是把每个边界框的六个平面(或十二三角形),并做以点上他们多边形测试的距离球体的中心。如果其中一个小于球体的半径,那么你有一个打击。

The next step would be to take each of the six planes (or twelve triangles) of the bounding box and do a distance from point to polygon test on them to the center of the sphere. If one of them is less than the radius of the sphere, then you have a hit.

Matlab的code多边形,以点距离:的http://www.mathworks.com/matlabcentral/fileexchange/12744-distance-from-a-point-to-polygon

Matlab code for polygon-to-point-distance: http://www.mathworks.com/matlabcentral/fileexchange/12744-distance-from-a-point-to-polygon

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

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