//Vernier clock plotter

//base has larger slots and smaller gaps, total number of slot/gap pairs is a multiple of the vernier multiplier
//rotor has slots no wider than base slots but no smaller than base gaps and should have slot/gap pairs that are multiplier+1
//this means base slot width/gap width = mult+1/mult
//and rotor slot width = base gap width, with rotor gap width as whatever is left

vmult=12; //vernier multiplier
routb=1.2; //outer radius base
routr=1.2; //outer radius rotor
rdraw=1.2; //plotted radius
rinh=0.6; //inner radius hour
rinw=0.3; //inner radius white
secs=0; //seconds of time to show on clock

base_width = 360/(vmult-1);
base_slot = base_width * ((vmult)/(2*vmult-1))*1.2; //size in degrees
base_gap = base_width - base_slot;
rotor_width = 360/(vmult);
rotor_slot = base_gap*1.5;
rotor_gap = rotor_width - rotor_slot;
fr=0;

boffset=-90+base_gap/2; //degrees offset for base slots
roffset=-90-rotor_slot/2; //degrees offset for rotor slots


for(secs=0)//linspace(0,60,30))
    drawlater
    clf
    title(msprintf("%f",secs))
    //gca().background = color("darkgray");
    plot2d(0,0,-1,"031"," ",[-rdraw,-rdraw,rdraw,rdraw])
    //gca().foreground = color("cyan1");
    xfarc(-routb,routb,2*routb,2*routb,0,360*64) //draw inner circle
    //xset("color",1) //black
    //gca().foreground = 1;
    for(v=1:vmult)
        xfarc(-routb,routb,2*routb,2*routb,(boffset + (v-1)*base_width)*-64,(base_slot)*-64);
    end
    //xset("color",2) //blue
    rsecs = secs/3600*(360/12);
    for(v=1:(vmult+1))
        xfarc(-routr,routr,2*routr,2*routr,(roffset + rsecs + (v-1)*rotor_width)*-64,(rotor_slot)*-64);
    end
    //xset("color",xget("white"))
    //gca().foreground = color("cyan1");
    xfarc(-rinh,rinh,2*rinh,2*rinh,0,360*64) //draw inner circle
    //gca().foreground = 1;
    xfarc(-rinh,rinh,2*rinh,2*rinh,(-180+rsecs)*-64,180*-64);
    //xset("color",xget("white"))
    //xfarc(-rinw,rinw,2*rinw,2*rinw,0,360*64) //draw inner circle
    //xarrows([0 rin*sin(rsecs/180*%pi)],[0 rin*cos(rsecs/180*%pi)]); //hour hand
    drawnow
    sleep(100)
    //xs2gif(gcf(),strcat(['VernierClock/frame',string(fr),'.gif']));
    fr=fr+1;
end

//set(gcf(), "visible","off","axes_size",[4000,4000]); // for instance
//xs2png(0, "C:\Users\zprog\Documents\Scilab\bigfig.png")

