POV-Ray : Newsgroups : povray.general : how to prevent overlapping random objects? : how to prevent overlapping random objects? Server Time
29 Jul 2024 20:27:31 EDT (-0400)
  how to prevent overlapping random objects?  
From: Simone
Date: 15 Aug 2010 14:25:02
Message: <web.4c6830857e94b25d7fd0e21e0@news.povray.org>
Hi,
I created a bunch of cylinders with a while loop and the rand() function.
But some of the cylinders are overlapping like in this picture:
http://alien23.de/test4/cylinders.jpg

The code I used was this:

#declare  zufall_1= seed (1199);
#declare  zufall_2= seed (342);

#declare ab=.09;  /// abstand

#declare Loop_x =0;

#declare Loop_x_end =9;

union {
#while (Loop_x < Loop_x_end)
        #declare Loop_y =0;
        #declare Loop_y_end =9;
        #while (Loop_y < Loop_y_end)

 #if (even (Loop_y))
                object { cyl  translate
<-.08+Loop_x*ab+rand(zufall_1)/15+Loop_x*.05 ,
Loop_y*ab+rand(zufall_1)/15+Loop_y*.035 , 0>   }

           #else
              object { cyl  translate <.1+Loop_x*ab-rand(zufall_1)/1+Loop_x*.05
, Loop_y*ab+rand(zufall_1)/16+Loop_y*.025 , 0> }
           #end

        #declare Loop_y=Loop_y+1;
        #end

#declare Loop_x=Loop_x+1;
#end
}

------------------------------------------------------
By now I've spent hours trying out other values for the cylinders' translation.
But when I use other values together with rand() I can prevent the cylinders
from overlapping but then everything looks too orderly.

So I basically want the bunch of cylinders to look like in the picture just
without the 4 or 5 overlapping cylinders.

I know it might work with the trace function to check whether they overlap and
so I read through Jonathan Hunt's pebbles.pov where he uses this.
But I found it very difficult and I don't know how too adapt the trace function
to my scene.

Or maybe it is possible to put all the translation data into an output file, and
manually edit the overlapping cylinders and then reimport it? But I have no clue
how to do this either.


Best wishes,

Simone


Post a reply to this message

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