POV-Ray : Newsgroups : povray.binaries.images : vlength [14.7kb] : vlength [14.7kb] Server Time
16 Aug 2024 18:18:57 EDT (-0400)
  vlength [14.7kb]  
From: marabou
Date: 5 Jan 2002 08:27:32
Message: <3c36ff40@news.povray.org>
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'
vlength.jpg


 

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