I wrote a C++ program that generates the scene you see in the attached
image. (40k non-intersecting spheres)
Now I'd like to change it to use many,many small cubes (randomly
rotated, of course), so I need an intersection formula for cubes.
I tried something like this: If one of the 8 corners of a cube is inside
the other one than the cubes intersect:
| for corner = cubeA.corner0 … cubeA.corner7:
| if( corner is_inside_of cubeB ) return true;
|
| for corner = cubeB.corner0 … cubeB.corner7:
| if( corner is_inside_of cubeA ) return true;
But it is possible that 2 cubes intersects even if none of the corners
is inside of the other cube. :-(
Has anyone a better formula for me?
Lars R.
Post a reply to this message
Attachments:
Download 't40kx.jpg' (108 KB)
Preview of image 't40kx.jpg'
![t40kx.jpg](/povray.binaries.images/attachment/%3C51028e21%40news.povray.org%3E/t40kx.jpg?preview=1)
|