POV-Ray : Newsgroups : povray.binaries.images : Hollow sphere, filled with shperes : Hollow sphere, filled with shperes Server Time
30 Jul 2024 02:13:44 EDT (-0400)
  Hollow sphere, filled with shperes  
From: Lars R 
Date: 25 Jan 2013 08:52:33
Message: <51028e21@news.povray.org>
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


 

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.