POV-Ray : Newsgroups : povray.newusers : loop 'falling over' : Re: loop 'falling over' Server Time
28 Jul 2024 14:25:44 EDT (-0400)
  Re: loop 'falling over'  
From: Chris B
Date: 21 Jan 2009 08:11:27
Message: <49771eff@news.povray.org>
"Graham" <nomail@nomail> wrote in message 
news:web.49770b5d59559b8e7fae05f50@news.povray.org...
> The attached file was an attempt on my part to resolve the problem of 
> randomly
> placing objects in a plane or region in a plane so that none of the items
> intersect.
>
> In any case, part way through the render it stops, usually after 4 items 
> are
> placed and usually before 12 items are placed on top of my cylinder.
>
> Can anyone explain why it falls over, and how to rectify it?
>
> The file (as a .txt) can be seen at:
>  http://docs.google.com/Doc?id=dc55n64c_1hsvhk6gm
>

Your inner loop is looping forever.
If you add:
  #debug concat("SizInt: ",str(SizInt,3,3),"\n")
to the end of your inner loop you'll see that it never reaches the end 
condition where SizInt>=6, so it keeps going.

I don't think the min_extents and max_extents functions are doing exactly 
what you think they're doing because I believe these work more on bounding 
boxes of the intersecting objects than on the actual bits of space occupied 
by the parts of the object. As soon as the bounding box from the union of 
dice fills the cylinder your condition therefore fails to end the loop, even 
though there's space available between the existing dice. ie it can't find a 
position where the bounding boxes don't intersect.

You're probably better off recording the centre positions of the dice in an 
array and looping through the array to see if the centre to centre distance 
of the next dice from each existing dice is large enough to avoid 
collisions.

Regards,
Chris B.


Post a reply to this message

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