立方体魔方碰撞检测算法? [英] Cube on Cube collision detection algorithm?

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

问题描述

我试图找到最有效的方法来检查,如果2任意大小的冰块互相碰撞。立方体的侧面不必都相等的长度(一个框是可能的)。由于这些限制,我怎么可能有效地检查,如果他们发生冲突? (每箱有24 verticies)谢谢

I'm trying to find the most efficient way to check if 2 arbitrarily sized cubes collide with each other. The sides of the cubes are not necessarily all equal in length (a box is possible). Given these constraints, how could I efficiently check if they collide? (each box has 24 verticies) Thanks

他们是神韵轴

推荐答案

由于这两个框是轴对准你可以比较它们的范围:

Since both boxes are axis-aligned you can just compare their extents:

  return (a.max_x() >= b.min_x() and a.min_x() <= b.max_x())
     and (a.max_y() >= b.min_y() and a.min_y() <= b.max_y())
     and (a.max_z() >= b.min_z() and a.min_z() <= b.max_z())

这篇关于立方体魔方碰撞检测算法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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