In this section I want to demonstrate some elementary
applications of the while loop in POV-Ray. | ||
First we consider a single loop which places little spheres along the x axis from x = 5 to x = +5: //------------------------------------ #declare Ball = sphere{<0,0,0>,0.5 texture{pigment{color Red} finish {ambient 0.15 diffuse 0.85 phong 1} } } #declare NrX = -5; // start #declare EndNrX = 5; // end #while (NrX < EndNrX+1) object{Ball translate <NrX,0,0>} #declare NrX = NrX + 1; //next Nr #end // ------------- end of loop ---- |
Scene file for | |
If we nest an existing loop in another loop which steps through the
values from | ||
//------------------------------------ #declare Boxy = box {<0,0,0>,< 1,1,1> scale 0.5 texture{pigment{color White} finish {ambient 0.1 diffuse 0.9}}} #declare DistanceX = 1.00; #declare DistanceZ = 1.00; #declare NrX = 0; // startX #declare EndNrX = 7; // endX #while (NrX < EndNrX) // <-- loop X #declare NrZ = 0; // start #declare EndNrZ = 7; // end #while (NrZ < EndNrZ) // <- loop Z object{Boxy translate<NrX*DistanceX, 0, NrZ*DistanceZ>} #declare NrZ = NrZ + 1; // next NrZ #end // --------------- end of loop Z #declare NrX = NrX + 1;// next NrX #end // ------------- end of loop X -- |
Scene file for | |
It is posibble to nest a nested loop in an additional
loop, which steps through the values from | ||
//------------------------------------ #declare DX = 1.00; #declare DY = 1.00; #declare DZ = 1.00; #declare NrX = 0; // startX #declare EndNrX = 5; // endX #while (NrX < EndNrX) #declare NrY = 0; // startY #declare EndNrY = 5; // endY #while (NrY < EndNrY) #declare NrZ = 0; // startZ #declare EndNrZ = 5; // endZ #while (NrZ < EndNrZ) object{Boxy translate <NrX*DX,NrY*DY,NrZ*DZ> } #declare NrZ = NrZ+1;// next NrZ #end // ---------- end of loop Z #declare NrY = NrY+1;// next NrY #end // ---------- end of loop Y #declare NrX = NrX+1;// next NrX #end // ----------- end of loop X ---- |
Scene file for | |
With this sample our possibilities regarding to pure linear transformations with loops seam to be exhausted in our three dimensional world. |
© Friedrich A. Lohmüller, 2004![]() homepage: |
![]() |
Visitors: ![]() since 08-May-1999 Thanks for your visit! |