两个通用六面体之间的碰撞检测 [英] Collision detection between two general hexahedrons

查看:139
本文介绍了两个通用六面体之间的碰撞检测的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个六面固体。的唯一保证是,它们各自具有8 vertex3f的(verticies与x,y和z分量)。鉴于此,我怎么能找到,如果这些发生碰撞?

I have 2 six faced solids. The only guarantee is that they each have 8 vertex3f's (verticies with x,y and z components). Given this, how can I find out if these are colliding?

推荐答案

看来我太愚蠢退出。

考虑这一点。如果固体1任何边缘相交的任何脸固体2,你有一个碰撞。这并不完全融为一体prehensive因为有当一个人被完全包含在其他的,您可以通过,如果任一中心包含在其他确定测试用例。

Consider this. If any edge of solid 1 intersects any face of solid 2, you have a collision. That's not quite comprehensive because there are case when one is is fully contained in the other, which you can test by determining if the center of either is contained in the other.

检查端面交集是这样工作的。

Checking edge face intersection works like this.

  1. 从一个顶点运行到另一个定义的边缘为载体开始。取,,边记下的长度。
  2. 由一个顶点,一个正常的,面内的基础上,并在此基础上,剩余的顶点的位置定义的平面段。
  3. 找到行的交点与平面的。在通常的配方,你将能够获得沿线无论是长度和平面内坐标相交的在你所选择的基础上
  4. 的交集必须行长度 [0,L] ,并且必须位于该数字在飞机里。这最后一部分是有点困难,但一个众所周知的通用解决方案
  1. Define the edge as vector starting from one vertex running to the other. Take note of the length, L, of the edge.
  2. Define the plane segments by a vertex, a normal, an in-plane basis, and the positions of the remaining vertices in that basis.
  3. Find the intersection of the line and the plane. In the usual formulation you will be able to get both the length along the line, and the in-plane coordinates of the intersection in the basis that you have chosen.
  4. The intersection must line as length [0,L], and must lie inside the figure in the plane. That last part is a little harder, but has a well known general solution.

这会工作。对于口才,我宁愿preFER <一href="http://stackoverflow.com/questions/3648285/collision-detection-between-two-general-hexahedrons/3648352#3648352">R..'s解决方案。如果你需要的速度......好吧,你只需要尝试一下吧。

This will work. For eloquence, I rather prefer R..'s solution. If you need speed...well, you'll just have to try them and see.

这篇关于两个通用六面体之间的碰撞检测的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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