POV-Ray : Newsgroups : povray.general : Even distribution on a sphere : Re: Even distribution on a sphere Server Time
5 Aug 2024 14:12:02 EDT (-0400)
  Re: Even distribution on a sphere  
From: Charles
Date: 20 Oct 2002 20:59:55
Message: <3DB351EF.4EC3A4BF@enter.net>
Tom Melly wrote:
> 
> Okay, I'm trying to randomly distribute objects, using trace, on a sphere.
> 
> So, I do something like:
> 
> RotZ = 180*rand(R1)
> RotY = 360*rand(R1)
> Trans = transform(translate y*10 rotate z*RotZ rotate y*RotY)
> TVec = vtransform(<0,0,0>, Trans)
> Inter = trace(Ob, TVec, -TVec)
> 
> The trouble is that I end up with a bunching of objects at the poles for all the
> obvious reasons, so the question is, how do I best avoid this? 


You want something that's completely random, yet nonetheless
uniform in its randomness? (Or would that be random in its
uniformity?) It sounds a bit like Vroomfondel demanding 
"rigidly defined areas of doubt and uncertainty." ;-)

It seems to me there's two problems with the above: First, the 
random factor is given far too much weight -- it should be subtler 
if you want uniformity of coverage. Second, to avoid clumps, a 
periodic function weighted into a loop increment might help. This 
almost certainly isn't what you're looking for, but hopefully it 
will be of some use in whatever solution you eventually come up 
with...

#declare Sphere1 = sphere { <0,0,0> , 1 }
#declare R1 = seed(0);

#macro RR(Factor)
    #local X = (rand(R1)-.5)*Factor;
    X
#end //RR

#macro Spikey(TargetSphere,Density,sTexture)
    #declare Y=0; #declare X=0.1; //very_small, but not 0 
                                  //or we'll loop forever.
    #while (Y < 360)
        #while (X < 179.9) // 180-very_small, same reason. 
            #local Trans = transform {rotate<X+RR(5),Y+RR(5),0>}
            #local TVec = vtransform(<0,10,0>, Trans );
            #local I1 = trace(TargetSphere, <0,0,0>, TVec);
            #local I2 = I1 *1.5;
            cone { I1, .1, I2, 0 texture{sTexture} }
            #declare X=X+Density*sin(radians(X));
        #end //Y<360
        #declare Y=Y+Density; #declare X=.1; 
    #end //X<180

    // Cover the singularity left by very_small...
    #local I1 = trace(TargetSphere, <0,0,0>, <0,1,0>);
    #local I2 = I1 *1.5;
    cone { I1, .1, I2, 0 texture{sTexture} }
    #local I1 = trace(TargetSphere, <0,0,0>, <0,-1,0>);
    #local I2 = I1 *1.5;
    cone { I1, .1, I2, 0 texture{sTexture} }

#end//Spikey

Spikey(Sphere1,5,texture{pigment {rgb<0,0,1>} })



-- 
@C[$F];
The Silver Tome ::  http://www.silvertome.com 
"You may sing to my cat if you like..."


Post a reply to this message

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