盒子/立方体与C#的交叉 [英] Intersection of boxes/cubes with C#

查看:74
本文介绍了盒子/立方体与C#的交叉的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检测两个未在C#中旋转的立方体的碰撞。如果如何计算相交量



我尝试过:



我试图使用这个基于矩形的例子来制作逻辑。

c ++ - 确定两个矩形是否相互重叠? - 堆栈溢出 [ ^ ]



但我卡住了不知道怎么回事

How to detect the collision of two cubes that are not rotating in C#. if how to calculate intersected volume

What I have tried:

I am trying to make logic with the use of this example which is based on rectangle.
c++ - Determine if two rectangles overlap each other? - Stack Overflow[^]

but i am stuck don't know how to preceed

推荐答案

每个立方体是由其在3d空间中的坐标限定的点集。



您可以为每个集合构建点序列然后使用LINQ设置操作以查找它们相交的位置。



或者,您可以迭代立方体A中的每个点,并将其光线投射到立方体B中;然后每个点击都是一个交集。



经过几次尝试后,你可能会想到一些优化(假设你从小立方体开始)。 br />


(实质上,你将立方体分成更小的立方体)。
Each cube is the set of points bounded by its coordinates in 3d space.

You can construct sequences of "points" for each set and then use LINQ set operations to find where they intersect.

Or, you can iterate every point in cube A, and "ray cast" it into cube B; where every "hit" is then an intersection.

After a few tries, you will probably think of some optimizations (assuming you start with "small" cubes).

(In essence, you're breaking cubes into smaller cubes).


这篇关于盒子/立方体与C#的交叉的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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