Povray example

by Oliver Knill This simple example has been implemented probably a thousand times in povray. It is simple enough, but shows different features of povray like the ability to program loops, place copies of objects.
#declare n=8; #declare m=16; 
#macro r(c) pigment{rgb c} finish {phong 1.0 ambient 0.5 diffuse 0.5} #end

camera{ location <8,40,1> right x up z look_at <8,0,0>}
plane { y, -1 texture{ r(<1,1,1>)} }
cylinder { < 0,-4,0>,< 0,10,0>,0.99  r(<0,0,1>) }
cylinder { <17,-4,0>,<17,10,0>,0.99  r(<0,0,1>) }
light_source{ <300,400,-500>  color rgb<1,1,1>}
background { rgb <1,1,1>}

#declare a=0.8; #declare l=7; #declare b=2; #declare d=1.5; #declare e=0.5;
#declare spin=difference{
  cylinder{<0,-a,0>,<0,a,0>, b}
  cylinder{<0,-1,0>,  <0,1,0>, 1}
  torus{b, 0.3 translate  a*y}
  torus{b, 0.3 translate -a*y} };

#declare ring= difference{
  cylinder{<0,-a,0>, <0,a,0>, l+1}
  cylinder{<0,-1,0>, <0,1,0>, l}
  torus{l,0.3 translate  a*y}
  torus{l,0.3 translate -a*y}};

#declare rod= union{
  box{<-e,-e,1.1>, }
  difference{
    box{<-d,-e,l-1>,}
    cylinder{<-d,-1,l-1>,<-d,1,l-1>,1}
    cylinder{< d,-1,l-1>,< d,1,l-1>,1} } };

#declare dent= difference{
  box{<-1.2,-a,0>,<1.2,a,1.3>}
  box{<-1,-b,-1>, <0,b,b> rotate  15*y translate -1*x}
  box{< 0,-b,-1>, <1,b,b> rotate -15*y translate  1*x}};

#declare rad= union{object{spin}
  object{ring}
  #declare k=0; #declare dkn=360/n; #declare dkm=360/m;  #declare w=7.8;
  #while (k<360) object{rod rotate k*y} #declare k=k+dkn; #end
  #declare k=0;
  #while (k<360) object{dent translate w*z rotate (k+10)*y} #declare k=k+dkm; #end};

object{rad rotate y*(360/( 2*m)+360*clock/n)                 texture{ r(<1,0,0>)}}
object{rad rotate y*(360/(12*m)-360*clock/n)  translate x*17 texture{ r(<0,1,0>)}}