简体   繁体   中英

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 .

I have a cube centre (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.

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.

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| S = |a| + |b| + |c| . The minimum is - S = - |a| - |b| - |c| - S = - |a| - |b| - |c| .

So it suffices to check if d falls in the range [-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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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