|
|
soemthing curious happened as i tried out vlength.
my aim was to put random spheres on the floor and the code itself has to
avoid intersections.
whenever i test about vlength i always get intersections between spheres.
my formular
#if ( (vlength(Mylist[Temp]-Random_Place)) > (2*Radi) )
takes no effect, whatever i put in for Radi from 0 till 0.5.
if i proof differences of Radi above 0.5 i get an error message that my
array is uninitialized.
maybe anyone can say what went wrong with the code.
attached is the scene which is everytime the same.
//----------------------------------------------code starts
#local Count = 50;
#local Counter = 0;
#local ix = seed(15);
#local ze = seed(5);
#local Mylist = array[Count]
#local Mylist[0]= <3*rand(ix),0,3*rand(ze)>;
#local Radi = 0.1; //takes no effect from 0 till 0.5 and above
#local NoGood = 1;
#while (Counter < Count)
//assume, sphere makes intersection
//if vlength > 2*Radi then draw sphere
#local NoGood = 1;
#while (NoGood)
#local Random_Place = <3*rand(ix),0,3*rand(ze)>;
#local Temp = 0;
#while (Temp <= Counter)
#if ( (vlength(Mylist[Temp]-Random_Place)) > (2*Radi) )
#local NoGood = 0;
#local Temp = Count+1;
#end
#local Temp = Temp + 1;
#end //while(Temp..
#end //while(NoGood)
#local Mylist[Counter] = Random_Place;
sphere {
<0,0,0>,1
scale <0.1,0.1,0.1>
pigment{color Green}
translate y*0.1
translate Mylist[Counter]
}
#local Counter = Counter + 1;
#end //while
//----------------------------------------------code ends
Post a reply to this message
Attachments:
Download 'vlength.jpg' (15 KB)
Preview of image 'vlength.jpg'
|
|