简体   繁体   English

检查由三个3D点组成的平面是否与立方体相交

[英]Check if a Plane ,formed by three 3D Points intersects a cube

I have a plane equation of form a*x + b*y + c*z + d = 0 . 我有一个形式为a*x + b*y + c*z + d = 0的平面方程。

I have a cube centre (x1,y1,z1). 我有一个立方体中心(x1,y1,z1)。

I want to check,if my plane intersects my cube. 我想检查一下飞机是否与立方体相交。

One procedure,I tried is to ,find all the vertices of the cube. 我尝试过的一种方法是,找到立方体的所有顶点。 Then,Substitute all the vertices in my plane equation. 然后,将所有顶点替换为我的平面方程式。 Now,lets call all the values as S11,...S88. 现在,让我们将所有值称为S11,... S88。

if((S11 > 0 && S22 > 0.........S88 > 0) || (S11 < 0 && S22 <0...S88<0)) then --> My plane does not intersect the cube,Since all the vertices have same sign. if((S11 > 0 && S22 > 0.........S88 > 0) || (S11 < 0 && S22 <0...S88<0)) then ->我的平面不相交由于所有顶点都有相同的符号。

But,this is not really an optimized solution.I would like to know any other easy approach,which is feasible in in terms of computational cost. 但是,这并不是真正的优化解决方案。我想知道任何其他简单的方法,就计算成本而言这是可行的。

Thanks. 谢谢。

Assuming a unit cube centered at the origin, ax + by + cz is maximized when the signs of x, y, z match those of a, b, c (to form three positive terms), and the maximum is S = |a| + |b| + |c| 假设单位立方体以原点为中心,则当x, y, z的符号与a, b, c的符号匹配(形成三个正项)时, ax + by + cz最大化,最大值为S = |a| + |b| + |c| S = |a| + |b| + |c| . The minimum is - S = - |a| - |b| - |c| 最小值为- S = - |a| - |b| - |c| - S = - |a| - |b| - |c| .

So it suffices to check if d falls in the range [-S, S] . 因此,只要检查d是否在[-S, S]范围内就足够了。

If the cube is not centered at the origin, not unit or not axis aligned, you can apply an affine transform to make it so, and apply the same transform to the plane before performing the test. 如果多维数据集不在原点中心,单位或轴未对齐,则可以应用仿射变换来进行仿射,并在执行测试之前将相同的变换应用于平面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM