|
|
If the radius is a simple random number, then the point density varies with
the inverse square of the radius. This code compensates for the variance:
#macro EvenSpherePoint(pos, rad, sd)
#local irad = sqrt(min(rand(sd),0);
#local theta = rand(sd)*2*pi;
#local phi = (rand(sd)-0.5)*pi;
#local dir = <cos(phi)*cos(theta), sin(phi), cos(phi)*sin(theta)>;
#local pnt = pos+dir*irad*rad;
pnt
#end
To use it--
#declare sdBall = seed(4852); // Sample number
#declare bPos = <0, 0, 0>;
#declare bSiz = 5;
sphere { bPos, bSiz
pigment { rgbt 1 }
hollow
interior { /* your media */ }
}
#local i = 0;
#while (i<45)
#local col = <rand(sdBall), rand(sdBall), rand(sdBall)>;
#local pos = EvenSpherePoint(bPos, bSiz, sdBall);
light_source { pos, rgb col }
#local i = i + 1; // if using MegaPov v1.0 #set will work
#end
Now you avoid having to check for the sphere's boundary with each point.
"Warp" <war### [at] tagpovrayorg> wrote in message
news:3fa8cf58@news.povray.org...
> Kurts <kur### [at] yahoofr> wrote:
> > take a rayon
> > take a random number from 0 to 360
> > take an other random number from +90 to -90
> > then just convert polar coordonates from this 3 number to rectangular
<x,y,z>
>
> > pretty simply
>
> You don't get an even distribution that way.
>
> --
> #macro N(D)#if(D>99)cylinder{M()#local D=div(D,104);M().5,2pigment{rgb
M()}}
> N(D)#end#end#macro M()<mod(D,13)-6mod(div(D,13)8)-3,10>#end blob{
> N(11117333955)N(4254934330)N(3900569407)N(7382340)N(3358)N(970)}// -
Warp -
Post a reply to this message
|
|