Paraxial Raytrace

Matlab code

function pray = parax(pstart, cv, th, rn)
%
%PARAX
%
% paraxial ray trace

pray(1,:) = pstart(1,:);
m = length(th);

if (nargin==3)
   for (n=2:m)
      pray(n,1) = pray(n-1,1)+ pray(n-1,2)*th(n-1);
      power = cv(n);
      pray(n,2) = pray(n-1,2) - power*pray(n,1); 
   end
else
   nu = rn(1)*pray(1,2);
   for (n=2:m)
      pray(n,1) = pray(n-1,1)+ pray(n-1,2)*th(n-1);
      power = (rn(n)-rn(n-1))*cv(n);
      nu = nu - power * pray(n,1);
      pray(n,2) = nu / rn(n);
   end
end
pray(m+1,1) = pray(m,1)+th(m)*pray(m,2);
pray(m+1,2) = pray(m,2);

Example

First we define the optical system.

>> th=[25 0.6 1.06541 0.15 1.13691  0.6  14.05015 ];
>> rn=[1  1.62  1      1.621   1      1.62    1];
>> cv=[0  0.25285 -0.01474 -0.19942 0.25973 0.05065 -0.24588 ];

Then we can generate a paraxial raytrace:

>> parax([-10 0.37],cv,th,rn)

ans =

  -10.0000    0.3700
   -0.7500    0.3010
   -0.5694    0.4928
   -0.0444    0.3006
    0.0007    0.4874
    0.5548    0.2901
    0.7289    0.3589
    5.7708    0.3589

We can also look at the system matrix, which tells us that the system is defined between conjugate planes of magnification -0.5771.

>> f = sysmatrix(cv,th,rn)

f =

   -0.5771   -0.1000
    0.0000   -1.7328

We can also find the effective focal length (efl)

>> efl = -1/f(1,2)

efl =

    9.9999


Maintained by John Loomis, last updated 3 Oct 1997