POV-Ray : Newsgroups : povray.binaries.images : vlength [14.7kb] : Re: vlength [14.7kb] Server Time
2 Nov 2024 03:15:37 EDT (-0400)
  Re: vlength [14.7kb]  
From: Jide
Date: 5 Jan 2002 09:29:18
Message: <3c370dbe$1@news.povray.org>
Jide wrote:
> I'd correct the code for you but my brain isn't functioning properly atm
:)
>
> -Jide

Ok ok. Couldn't resist. Hope outlook won't screw up the wrapping.
Oh and btw. If at some point it parses WAY too long then lower
NumBalls or increase the possible area of Random_Place (ie.
<5*rand(Seed),0,5*rand(Seed)>.

//----------------------------------------------code starts
#local NumBalls = 100;
#local Counter = 1;
#local Seed = seed(4);
#local Mylist = array[NumBalls]
#local Mylist[0]= <3*rand(Seed),0,3*rand(Seed)>;
#local Radi = 0.1;      //takes no effect from 0 till 0.5 and above
#while (Counter < NumBalls)
  #local Good = 1; //Assume there is no intersection
  #local Random_Place = <3*rand(Seed),0,3*rand(Seed)>;
  #local Temp = 0;
  #while (Temp < Counter)
    #if ( (vlength(Mylist[Temp]-Random_Place)) < (2*Radi) )
      #local Good = 0;
        //But if even 1 intersection is found then reject the random point
    #end
    #local Temp=Temp+1;
  #end //while (Temp <= Counter)
  #if(Good)
    #local Mylist[Counter] = Random_Place;

    sphere {
      <0,0,0>,Radi
      pigment{color Green}
      translate y*Radi
      translate Mylist[Counter]
    }

    #local Counter=Counter+1;
  #end  //if (Good)
#end //while

//----------------------------------------------code ends

-Jide


Post a reply to this message

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