POV-Ray Raytracer Descriptions and Examples by Friedrich A. Lohmüller
   Random with POV-Ray (Part 2)
Italiano Italiano
Français français
Deutsch Deutsch

Home
- POV-Ray Tutorial

Random in POV-Ray
   - RandomNumbers in Loops
  > quadratic + cubic
   - Colors + Scale
   - Tilting + Bending
   - Trees by Random
   - Include File 'rand.inc'
   - Filled height_field
   - Random Flower

  - Insert Menu Add-on
    & Download
 
                                       
 Irregularity quadratic and cubic      

Here we see how to arrange objects 3dimensional and 3dimensional in a randomly irregularity.
We use a serie of spheres, which we arrange with a while loop.

Here the random arrangement in a plane:
//--------------------------------------
// Choosing random series:
#declare Random_1 = seed (2655);
#declare Random_2 = seed (1153);
//--------------------------------
union{
 // outer loop -------------------
 #declare NrX = - 2.5;  // start x
 #declare EndNrX =  2.5;// end   x
 #while (NrX< EndNrX+1)
  // inner loop ------------------
  #declare NrZ = 0;     // start z
  #declare EndNrZ =  5; // end   z
  #while (NrZ< EndNrZ+1)

  sphere{ <0,0,0>, 0.5
    texture{ pigment{color rgb<1,.65,0>}
             finish {phong 1}
           } // end of texture
    // regulare arrangement:
    //translate< 2*NrX, 0.5, 2*NrZ>

    // randomized arrangment:
    translate
     < 2*NrX+1.5*(-0.5+rand(Random_1)),
       0.5,
       2*NrZ+1.5*(-0.5+rand(Random_2))
     >
  } // end of sphere --------------

  #declare NrZ = NrZ + 1; // next Nr z
  #end // -------------- end of loop z
  // end inner loop
 #declare NrX = NrX + 1;  // next Nr x
 #end // --------------- end of loop x
// end of outer loop
} // end of union ----------------------


 

And now all in three dimensions:
//------------------------------------
// Choosing random series:
#declare Random_0 = seed (91125);
#declare Random_1 = seed (2655);
#declare Random_2 = seed (1153);
//--------------------------------
union{
 // outer loop -------------------
#declare NrX = -3;  // start x
#declare EndNrX =  3;// end   x
#while (NrX< EndNrX+1)
 // more inner loop --------------
 #declare NrY = -3;   // start y
 #declare EndNrY = 3; // end   y
 #while (NrY< EndNrY+1)
  // innerst loop ----------------
  #declare NrZ = -3;   // start z
  #declare EndNrZ = 3; // end   z
  #while (NrZ< EndNrZ+1)

  sphere{ <0,0,0>, 0.15
   texture{pigment{color rgb<1,.65,0>}
           finish {phong 1}
          } // end of texture
   // regulare arrangement:
   //translate<0.5*NrX,0.5*NrY,0.5*NrZ>

   // randomized arrangment:
   translate
   <0.5*NrX+0.25*(-0.5+rand(Random_0)),
    0.5*NrY+0.25*(-0.5+rand(Random_1)),
    0.5*NrZ+0.25*(-0.5+rand(Random_2))>
  } // end of sphere --------------

  #declare NrZ = NrZ + 1; // next Nr z
  #end // -------------- end of loop z
  // end innerst loop
 #declare NrY = NrY + 1; // next Nr y
 #end // -------------- end of loop y
 // end more inner loop
#declare NrX = NrX + 1;  // next Nr x
#end // --------------- end of loop x
// end of outer loop
rotate <0,-40,0>
translate <0,2,2>}
} // end of union --------------------


 
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 |
top

© Friedrich A. Lohmüller, 2013
www.f-lohmueller.de