POV-Ray : Newsgroups : povray.binaries.images : Placing random spheres (~330k in attachments) : Re: Placing random spheres (~330k in attachments) Server Time
7 Aug 2024 13:16:24 EDT (-0400)
  Re: Placing random spheres (~330k in attachments)  
From: Sven Littkowski
Date: 16 May 2006 13:02:26
Message: <446a05a2$1@news.povray.org>
Greetings, and thanks for your answer.

Yes, I would be interested to see how the code for the object distribution 
would be. I tried on my own, a few successless times before, but had not 
even the right beginning idea.

And to be honest, if you could show me how to trace the surface(s) of an 
object on which the objects should be distributed, I would appreciate it a 
lot! I am asking, because I also have no idea how to do that.

Thanks,

Sven



"Warp" <war### [at] tagpovrayorg> schrieb im Newsbeitrag 
news:4469e328$1@news.povray.org...
> Sven Littkowski wrote:
>> Let's say, I intend to place a ramdom-generated pattern of spheres (such 
>> as yours) on an unequal surface (maybe a heightfield or a union of 
>> objects).
>
>   My method can actually be used for any distributions of spheres,
> not just a plane. You only have to come up with a formula which
> calculates a random placement for the spheres in whatever shape
> you want (eg. the surface of an object). Of course with certain
> shapes calculating an even distribution may not be as trivial
> as a simple <rand(S), rand(S), rand(S)> (for example distributing
> points about evenly on the surface of a sphere requires a function
> slightly more complicated).
>   If you want to place spheres on the surface of an object you'll
> have to use trace to get points on that object and figure out a
> way to distribute these points approximately equally on the surface
> of the whole object (with a spherical surface it's rather easy but
> with other more irregular surfaces it can be more difficult).
>
>> How, then, would the code look alike? Can you help me?
>
>   The naive approach is to simply store the locations of the spheres
> already created in an array and then when a new sphere is created,
> check it against each coordinate in this array (iow. check if the
> center of the sphere you just created is closer than the diameter
> of the sphere to any of the coordinates in the array; if it is closer
> to any of the points, then it's not ok and you have to create another
> location for the new sphere; after you successfully create it, add
> its center coordinates to the array).
>
>   My optimized method uses this basic approach but I figured out a
> rather simple way of speeding up the check a *lot*.
>   The good thing about this approach is that you can have *any*
> distribution for the spheres you like (eg. on the surface of any
> object or whatever), and this algorithm will never produce spheres
> which are intersecting.
>
>   I can post a description of my simple method in povray.general if
> people are interested. (It's probably nothing new and other people
> have probably already thought of it, but perhaps my specific approach
> is more resource-friendly than most other attempts.)


Post a reply to this message

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