// Persistence of Vision Ray Tracer Scene Description File
// File: ?.pov
// Vers: 3.5
// Desc: Basic Scene Example
// Date: mm/dd/yy
// Auth: ?
//

#version 3.5;

#include "colors.inc"
global_settings {
  assumed_gamma 1.0
  ambient_light color rgb <1,1,1>
}
#declare potential=function(xx,yy,zz){
     yy/pow(xx*xx+yy*yy+zz*zz,1.5)    //ptential for a dipole at the origin
}
#declare dd=1e-6; //interval length for estimating derivatives
#declare Fx=function(xx,yy,zz){
     (-potential(xx+dd,yy,zz)+potential(xx,yy,zz))/dd
}
#declare Fy=function(xx,yy,zz){
     (-potential(xx,yy+dd,zz)+potential(xx,yy,zz))/dd
}
#declare Fz=function(xx,yy,zz){
     (-potential(xx,yy,zz+dd)+potential(xx,yy,zz))/dd
}
#declare ds=.02;
#declare lines=union{
     #declare aang=15;
     #while(aang<45)
          #switch (aang)
               #range (0,5)
                    #declare aztot=1;
                    #declare maxlen=3;
               #break //Third case ends
               #range (5,29)
                    #declare aztot=6;
                    #declare maxlen=20;
               #break //Third case ends
               #range (29,60)
                    #declare aztot=6;
                    #declare maxlen=20;
               #break 
               #else
                    #declare aztot=6;
                    #declare maxlen=20;
          #end 
          #declare aznow=0;
          #while(aznow<aztot)
               #declare start =vrotate(vrotate(.3*y,aang*z),y*aznow*360/(aztot));
               #declare ss=0;
               #declare new=start;
               /**/
               
               #while(ss<maxlen) 
                    #declare old=new;
                    #declare rx=old.x;
                    #declare ry=old.y;
                    #declare rz=old.z;
                    #declare Fv=<Fx(rx,ry,rz),Fy(rx,ry,rz),Fz(rx,ry,rz)>; 
                    #declare new=old+ds*Fv/vlength(Fv);
                    #if(new.y<0)
                         #declare ss=maxlen;
                    #end     
                    cylinder { old, new, .02      no_shadow no_reflection}
                    #declare ss=ss+ds;
               
               #end
               #declare aznow=aznow+1;
          #end
          #declare aang=aang+30;
     #end
}
#declare allines=union{
     object{lines}
     object{lines scale <1,-1,1>}
     texture {
       pigment { color rgb <.0,.1,0>      }
       finish { ambient 0.95   specular 0.2 }
     }
     no_shadow
     no_reflection
}
#declare nstar=sphere { <0, 0, 0>, 0.5 
     texture {
       pigment { color rgb <.1,.1,6>      }
       finish { ambient 0.35   specular 0.1 }
     }
texture {
  pigment {          // (---surface color---)
    marble           // some pattern
    color_map {      // color map
      [0.1 color rgb <.1,.0,.4>]
      [0.3 color rgb <.3,.0,.7>]
      [0.5 color rgb <.1,.0,.4>]
      [0.7 color rgb <.3,.0,.7>]
    }
    turbulence 2.3   // some turbulence
  }
  normal {           // (---surface bumpiness---)
    marble 0.5       // some pattern (and intensity)
    turbulence 2.3   // some turbulence
  }
  finish {           // (---surface finish---)
    ambient 0.5
    specular 0.5     // shiny
  }
}
     no_shadow
     no_reflection
     hollow

}
#declare nstarall=union{
object{allines}
object{nstar}
     no_shadow
     no_reflection
     hollow

}
//axis
/* */
cylinder { -2*y, 2*y, .02 
      texture {
       pigment { color rgb <.2,.1,.2>      }
       finish { ambient 0.85   specular 0.0 }
     }
     no_shadow
     no_reflection
     hollow
}






#declare lclock=clock+.0;
object{nstarall
     rotate -z*30
     rotate y*360*lclock

} /**/

#declare beamdir=vrotate(vrotate(4*y,-z*30),y*360*lclock);

light_source {
  0*x                     // light's position (translated below)
  color rgb <1,1,2>*5       // light's color
  spotlight               // this kind of light source
  point_at beamdir      // direction of spotlight
  radius 1                // hotspot (inner, in degrees)
  tightness 1            // tightness of falloff (1...100) lower is softer, higher is tighter
  falloff 8               // intensity falloff radius (outer, in degrees)
}
light_source {
  0*x                     // light's position (translated below)
  color rgb <1,1,2>*5       // light's color
  spotlight               // this kind of light source
  point_at -beamdir      // direction of spotlight
  radius 1                // hotspot (inner, in degrees)
  tightness 1            // tightness of falloff (1...100) lower is softer, higher is tighter
  falloff 8               // intensity falloff radius (outer, in degrees)
}
 background { rgb 0 }

 sphere
 {0, 60
   pigment { rgbt 1 } hollow
   interior
   { media
     { scattering { 4, 0.07 extinction 0.0125 }
       samples 40,100
     }
   }
 }

/**/




// ----------------------------------------

camera {
  location  <0.0, 6, -4.0>*6
  direction 1.5*z
  right     x*image_width/image_height
  look_at   <0.0, 0.0,  0.0>
  angle 20
}
/*
light_source {
  <0, 0, 0>            // light's position (translated below)
  color rgb <1, 1, 1>  // light's color
  translate <-30, 30, -30>
}
*/
