POV-Ray : Newsgroups : povray.general : Algorithm-approach to eliminate intersections... : Re: Algorithm-approach to eliminate intersections... Server Time
6 Aug 2024 08:12:31 EDT (-0400)
  Re: Algorithm-approach to eliminate intersections...  
From: John VanSickle
Date: 21 Jun 2002 17:49:42
Message: <3D139F8B.9CE6B241@hotmail.com>
Tim Nikias wrote:
> 
> Nontheless, I'm thinking how I can simplify the method of
> counter-checking every new object with ALL objects
> that were formerly generated. I do know of the subdivision
> method, i.e. creating several blocks and only checking in
> those and the nearest blocks, but are there any different
> approaches, like sorting all positions somehow?

Make a big two-dimensional array.  Initialize each value to a negative
number, equal to the radius of the largest object you'll be placing.

Map each object to a position in this array.  Fill in this position with
the radius of the object, plus the amount of whatever
minimum clearance you want between objects.  Fill in the surrounding
spaces with values that decrease from this amount in a linear fashion,
depending on the distance represented between the two; except that
a higher value is never replaced with a lower one.

For each object placed thereafter, check the position in the array
that maps to the center of the object to be placed; if the value at
that spot, plus the radius of the object, is greater than zero, the
object will overlap another; pick another spot.

The array doesn't need to be that precise.

Can't figure out how to tell when the array is full, other than a
brute-force check of the entire array.

Regards,
John


Post a reply to this message

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