#version 3.5;

#include "colors.inc"
// general math functions and macros
// 
#include "math.inc"
#include "golds.inc"
#include "metals.inc"
#include "shapes.inc"

#include "textures.inc"
#include "mrg_misc.inc"

global_settings{
        assumed_gamma 1
        ambient_light rgb<1, 1, 1>
}
background  {<1,1,1>}

#declare lclock = clock+.2;
        

#declare head_length = .3;
#declare post_diameter=.05;
#declare head_diameter=3*post_diameter;

//The vectors:
#declare A = 3*x;
#declare B=vrotate(2*x,360*z*lclock);

object{
        Make_Vector(A,head_length,post_diameter,head_diameter)
        texture{pigment { color rgbt <.1,.1,.8,0> } finish{ambient .8 diffuse 1}}
        no_shadow
        no_reflection
        }

object{
        Make_Vector(B,head_length,post_diameter,head_diameter)
        texture{pigment { color rgbt <.4,.4,.4,0> } finish{ambient .8 diffuse 1}}
        no_shadow
        no_reflection
        }
intersection{
        torus { 1, post_diameter*.5 }
        Wedge(360*lclock)
        rotate y*90
        rotate x*90
        texture{pigment { color rgbt <1,.4,.2,0> } finish{ambient .8 diffuse 1}}
        no_shadow
        no_reflection

}

//dot indicator
#declare indicator_value = cos(lclock*2*pi);
#declare ybottom = min(indicator_value,-.001);
#declare ytop = max(indicator_value,.001);
union{
        //indicator
        cylinder{<0,0,0>,<0,ytop,0>, 1  
                texture { pigment { color <0.1, 0.7, .1>  } }
                        finish{ambient 1.0 diffuse 0}
                } 
        cylinder{<0,0,0>,<0,ybottom,0>, 1  
                texture { pigment { color <0.7, 0.1, .1>  } }
                finish{ambient 1.0 diffuse 0}
        } 
        //frame
        union{
        cylinder{<1,1,0>,<1,-1,0>, .04}
        cylinder{<1,-1,0>,<-1,-1,0>, .04}
        cylinder{<-1,-1,0>,<-1,1,0>, .04}
        cylinder{<-1,1,0>,<1,1,0>, .04}
        texture { pigment { color Black  } }
        }
        scale <.2,.4,.02>
        translate <3.45,+1.5,.1>
      }
  text {
    ttf "Times" "A·B" .005, 0
    pigment {color Black}
    scale .4
    //rotate <0,rottxt,0> 
    translate <3.1,.65,0>
  }
cylinder{-.01*z,.01*z,.04 translate <3.42,.77,0>}

plane { z, 0 //the grid 
 texture{
        pigment {
           brick color rgbt <0,0,0,0>, color rgbt <1,1,1,1>
           brick_size 1 mortar .025
           rotate x*90 translate .5*y
         }
 }
}

// perspective (default) camera
camera {
  location  <0, 0, -200.0>
  look_at   <0, 0,  0.0>
  right     x*image_width/image_height
  angle 2.5
}
