%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% eyepiece_ramsden.m
%
% Simple Ramsden type eyepiece design using thin lenses.
%
%  It consists of two positive lenses made of
%  same type of glass. Doublet must be separated by a distance
%  equal to one-half the sum of their focal lengths.
%   d = (f1+f2)/2
%  Then, focal length of the system can be found from:
%   2/f = 1/f1+1/f2
%  It is suggested that to use the relation
%   f1 = 1.5*f2
%  Hence in terms of (f)
%   f1 = 5*f/4 and f2 = 5*f/6
%  If the lenses are plano-convex, then radius of curvatures
%  are as follows:
%   R12 = -(n-1)*f1, R11 = inf
%   R21 = +(n-1)*f2, R22 = inf
%  where n is the index of refraction.
%
% Inputs:
%         f  Focal length of system
%         n  Refractive indices of the glass
%        t1  center thickness of the first lens
%        t2  center thickness of the second lens
% Outputs:
%         R  Radii of curvatures of lenses
%         d  distance between lenses
%
% Mar 2023
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear; clc;

% inputs
f  = 28;
n  = 1.5168; % for d-line of BK7
t1 = 3.5;
t2 = 4.5;

% calculations
f1 = 5*f/4;
f2 = 5*f/6;
R1 = inf;
R2 = -(n-1)*f1;
R3 = +(n-1)*f2;
R4 = inf;
d  = (f1+f2)/2 - (t1+t2);

% outputs
fprintf('Ramsden system focal length = %9.4f\n',f);
fprintf('1st lens:\n');
fprintf('  R11 = %9.4f\n',R1);
fprintf('  R12 = %9.4f\n',R2);
fprintf('  t1  = %9.4f\n',t1);
fprintf('2nd lens:\n');
fprintf('  R21 = %9.4f\n',R3);
fprintf('  R22 = %9.4f\n',R4);
fprintf('  t2  = %9.4f\n',t2);
fprintf('Distance between lenses:\n');
fprintf('  d   = %8.4f\n',d);
