%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% cassegrain.m
%
% Cassegrain telescope design
% Inputs:
%    F   System focal length
%    D   Distance between primary and secondary mirrors
%    B   Distance between sencondary mirror and final focus (Back Focus)
%    d   Diameter of primary mirror for f/# calculation
%
% Outputs:
%    R1  Radius of primary mirror
%    R2  Radius of secondary mirror
%    k1  Conic constant of primary mirror
%    k2  Conic constant of secondary mirror
%    fn  f-number of the system
%    df  Depth of focus in um for wavelengths {0.4,0.5,0.6} um
%
% Nov 2021
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear; clc;

F = 1000;
B = 400;
D = 340;
M = (F-B)/D; % magnification
d = 100;

% f-number and depth of focus
fn = F/d;
df = 2*[0.4 0.5 0.6]*fn^2;

% radius of curvatures
R1 = -2*D*F/(F-B);
R2 = -2*D*B/(F-B-D);

% conic constants
k1 = -1;
k2 = -(M+1)^2/(M-1)^2;

fprintf('EFFL    = %10.3f mm\n',F)
fprintf('f/#     = %10.3f\n',fn)
fprintf('df(0.4) = %6.1f um\n',df(1))
fprintf('df(0.5) = %6.1f um\n',df(2))
fprintf('df(0.6) = %6.1f um\n\n',df(3))
fprintf('R1      = %10.3f mm\n',R1)
fprintf('R2      = %10.3f mm\n',R2)
fprintf('k1      = %10.3f\n',k1)
fprintf('k2      = %10.3f\n',k2)
