Descriptions and Examples for the POV-Ray Raytracer by Friedrich A. Lohmüller
About Loops with POV-Ray     
Italiano Italiano
Français français
Deutsch Deutsch

Home
- POV-Ray Tutorial

  Loops in POV-Ray
  1. Loops For + While
       Comparison
  2. Linear
      Transformations
  3. Circular
      Transformations
  4. Moebius etc.
  5. Screws
       & Spirals
  6. Twisting
       Spirals
  7. Snails
       & Ammonites
  8. Spherical Spirals 1
  9. Spherical Spirals 2
>10. Fibonacci Spirals
                                       
 
 
  - Download

Spirals by Fibonacci Numbers    

Here we use the proportion between two Fibonacci numbers
to calculate the rotation angle of the spiral elements.
#local R = 0.25; // start radius
#local Nr = 0;          // start
#local End_Nr = 37;     // end
#while ( Nr <= End_Nr ) // loop
 sphere{ <0,0,0>, R*0.25 //------------
         scale <1,0.6,1>
         texture{
           pigment{color rgb<0.8,1,0>}
           finish {phong 1}
         } //--------------
         translate <R,0,0>
         rotate <0,-Nr*360*(8/13),0>
      } //-----------------------------
 #local R = R*1.05; // growing radius
 #local Nr = Nr + 1;    // next Nr
 #end // ---------------  end of loop
The same precedure with a for-loop:
#local R = 0.25; // start radius
//#for(Identifier,Start,End[,Step])
#for ( Nr , 0, 37, 1 )
 sphere{ <0,0,0>, R*0.25 //------------
         scale <1,0.6,1>
         texture{
           pigment{color rgb<0.8,1,0>}
           finish {phong 1}
         } //--------------
         translate <R,0,0>
         rotate <0,-Nr*360*(8/13),0>
      } //-----------------------------
 #local R = R*1.05; // growing radius
 #end // ---------------  end of loop
// Fibonacci numbers:
// Rules: A(1)= 1; A(2) = 1; and
//            for N>2: A(N) = A(N-1) + A(N-2).
// 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, ...

Scene file for POV-Ray: FibonacciSpiral_01.pov
or: FibonacciSpiral_01.txt

With a linear growing of the radius R
we get the following form:
#local R = 0.018; // start radius
#local Nr = 0;          // start
#local End_Nr = 300;    // end
#while ( Nr <= End_Nr ) // loop
 sphere{ <0,0,0>,0.25 + Nr*0.0015 //----
         scale <1,1.6,1>
         texture{
           pigment{color rgb<1,0.7,0>}
           finish {phong 1}
         } //--------------
         translate <R*0.65,0,0>
         rotate <0,-Nr*360*(34/89),0>
      } //-----------------------------
 #local R = R+0.038; // growing radius
 #local Nr = Nr + 1;    // next Nr
 #end // ---------------  end of loop
Scene file for POV-Ray: FibonacciSpiral_05.pov
or: FibonacciSpiral_05.txt


top

© Friedrich A. Lohmüller, 2014
http://www.f-lohmueller.de