|
|
Wasn't it marabou who wrote:
>
>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.
Your code looks for a random location for which there is at least one
ball that is at least (2*Radi) away. It only needs to find one such ball
to decide that the new location is OK, therefore it considers just about
everywhere to be OK.
What you ought to be looking for is a location for which *all* the balls
are at least (2*Radi) away. Like:-
#local Good = 0;
#while (Good = 0)
#local Random_Place = <3*rand(ix),0,3*rand(ze)>;
#local Temp = 0;
#local Good = 1;
#while (Temp < Counter)
#if ( (vlength(Mylist[Temp]-Random_Place)) < (2*Radi) )
#local Good = 0;
#end
#local Temp = Temp + 1;
#end //while(Temp..
#end //while(Good=0)
You now have to keep Radi below about 0.17 or there won't be anywhere
left to place the 50th ball, and the code will loop forever.
--
Mike Williams
Gentleman of Leisure
Post a reply to this message
|
|