//mirror reflected beam path calculator
//for spinning mirror at phi=45 degrees
//and lasers arranged in a uniform circle at phi=0 degrees

//for this case it is numerically shown that, with -%pi/2 < mirror theta < %pi/2
// laser spot theta = sign(mirror_theta) * (%pi/2) + mirror_theta
// laser spot phi = (%pi/2) - abs(mirror_theta)
npts=100;
mirror_theta=linspace(0,%pi/2,npts);
intpts=zeros(2,npts);
intpts(1,:)=%pi/2+mirror_theta;
intpts(2,:)=%pi/2-mirror_theta;
px=[cos(intpts(1,:)).*cos(intpts(2,:));sin(intpts(1,:)).*cos(intpts(2,:));sin(intpts(2,:))];
dx=sqrt(sum((px(:,2:$)-px(:,1:($-1))).^2,1));
L=2*sum(dx); //double since we only considered positive mirror_theta

r=2; //[m] radius of projected surface sphere
hz=30; //[hz] revolution rate of mirror
mt=(1/hz)/2;//[s] time to complete path
lpl=L*r;
lps=lpl/mt;
mprintf("Laser path length = %f m, avg speed = %f m/s\n",lpl,lps);
