% calculating the angular displacement off the resonant axis for HIFOX and
% HIFOY assuming the same pitch motion of the OPLEVs
% Reference: Seigman Laser chapter 19

% For HIFO-X ROC
ITMX= 1939.52;
R1_X = ITMX;
ETMX= 2241.54;
R2_X = ETMX;

% For HIFO-Y ROC (T1300158)
ITMY = 2307;
R1_Y = ITMY;
ETMY = 2313;
R2_Y = ETMY;

% constants
L = 3994.472; % alog 9402 
c = 299792458; %m/s
lambda = 532e-9;

% angular fluctuations
Theta1 = .1e-6; %itmx radians
Theta2 = .1e-6; %etmx radians

% g paramters
g1_Y = 1-L/R1_Y;
g2_Y = 1-L/R2_Y;
g1_X = 1-L/R1_X;
g2_X = 1-L/R2_X;

% spot size (diameter in m)
w1_X = sqrt(lambda*L/pi * sqrt(g2_X/(g1_X*(1-g1_X*g2_X))));
w2_X = sqrt(lambda*L/pi * sqrt(g1_X/(g2_X*(1-g1_X*g2_X))));
w1_Y = sqrt(lambda*L/pi * sqrt(g2_Y/(g1_Y*(1-g1_Y*g2_Y))));
w2_Y = sqrt(lambda*L/pi * sqrt(g1_Y/(g2_Y*(1-g1_Y*g2_Y))));

A1_X = g2_X/(1-g1_X*g2_X);
A2_X = 1/(1-g1_X*g2_X);
A3_X = g1_X/(1-g1_X*g2_X);
A1_Y = g2_Y/(1-g1_Y*g2_Y);
A2_Y = 1/(1-g1_Y*g2_Y);
A3_Y = g1_Y/(1-g1_Y*g2_Y);

delta_x1_X = A1_X * L*Theta1 + A2_X * L*Theta2;
delta_x2_X = A2_X * L*Theta1 + A3_X * L*Theta2;
delta_x1_Y = A1_Y * L*Theta1 + A2_Y * L*Theta2;
delta_x2_Y = A2_Y * L*Theta1 + A3_Y * L*Theta2;

delta_theta_X = (delta_x2_X - delta_x1_X)/L;
delta_theta_Y = (delta_x2_Y - delta_x1_Y)/L;

rel_ang_disp = delta_theta_X/delta_theta_Y

% ratio btwn translation relative to optical axis and beam size

ETM_to_ETM =(A3_X/w2_X) / (A3_Y/w2_Y)
ETM_to_ITM =(A2_X/w1_X) / (A2_Y/w1_Y)
ITM_to_ETM =(A2_X/w2_X) / (A2_Y/w2_Y)
ITM_to_ITM =(A1_X/w1_X) / (A1_Y/w1_Y)

% T030120 eigenvalue equation (10)
k_X = (g1_X + g2_X + sqrt(4+(g1_X - g2_X)^2)) / (2*(1-g1_X*g2_X))
k_Y = (g1_Y + g2_Y + sqrt(4+(g1_Y - g2_Y)^2)) / (2*(1-g1_Y*g2_Y))

