POV-Ray : Newsgroups : povray.advanced-users : Something more theoretical.... : Re: Something more theoretical.... Server Time
29 Jul 2024 12:20:38 EDT (-0400)
  Re: Something more theoretical....  
From: JRG
Date: 16 Apr 2002 18:02:30
Message: <3cbc9f76@news.povray.org>
"Jan Walzer" wrote:
>
> lets see, if I understood this correct ...
>
> You say, that I should first place all the spheres in a grid, and then jitter this
> to make a random distribution ? ... sounds interesting ...

Ideally. In fact you jitter the spheres as you place them. You should come up with
something like:

#declare N = 400;
#declare L = 0.3+1; //max_radius + epsilon
#declare RS = seed (123);
union {
#local i=0;
#while (i<sqrt(N))
#local j=0;
#while (j<sqrt(N))
#declare RADIUS = 0.1+0.2*rand(RS); // your function here
sphere {
0,RADIUS
translate <i*L -(L/2-RADIUS)+2*(L/2-RADIUS)*rand(RS), RADIUS, j*L -
(L/2-RADIUS)+2*(L/2-RADIUS)*rand(RS)>
pigment {rgb 1}
}
#local j=j+1;
#end
#local i=i+1;
#end
}

The pitfall of this approach is that not always it's that easy to get a reasonably
random look (you can try increasing the maximum translation amount till you can
observe clear intersections).
There's almost no parsing time...


> > I did it once. IIRC it was a real puzzle, I began to meet arrays in my not so
quiet
> > dreams... :-|
>
> that doesn't sound nice ... you mean I should leave this to an external program ?

You mean an external language (like C)? That would make it faster and simpler, but
you would lose flexibility.

--
Jonathan.

Home: http://digilander.iol.it/jrgpov


Post a reply to this message

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