ABDEMO Demonstrates aberrations at a spherical air-glass interface

Demonstration is done by ray tracing using raysphere;

Usage: ABDEMO;

Requires; RAYSPHERE See also; RAYSPHERE, ASTIG, COMA, CHROMATIC

by Chuck DiMarzio Northeastern University April 2009

!! This file may be copied, used, or modified for educational and
!! research purposes provided that this header information is not
!! removed or altered, and provided that the book is cited in
!! publications, as DiMarzio, Charles A., Optics for Engineers,
!! CRC Press, Boca Raton, FL, 2011.
!! http://www.crcpress.com
!! Other distribution is prohibited without permission.

Contents

Set up parameters for the problem

zobject=-10;
p0=[0,0,zobject]'; % object location on the z axis
r=2; % radius of sphere
pc=[0,0,r]'; % sphere center
n=1.5; % index of refraction of glass
zimage=n/((n-1)/r-1/(-zobject));
endplane=1.2*zimage;  % end plane for displaying rays
%
zplot=[];xplot=[]; % arrays for plot variables
%
hmax=1;  % Maximum height of ray above lens vertex

Trace rays exactly

for h=(0:0.2:1)*hmax; % Loop on rays: h is height above vertex
  v=[h,0,sqrt(zobject^2-h^2)]';
  v=v/sqrt(v'*v);
  [s1,s2]=raysphere(p0,pc,v,r);
  p1=p0+s1*v;
  nor=-(p1-pc)/sqrt((p1-pc)'*(p1-pc)); % Unit normal
  vnew=v/n+(sqrt(1-(1/n)^2*(1-(v'*nor)^2))-v'*nor/n)*nor;
  p2=p1+vnew/vnew(3)*(zimage-p1(3));
  p3=p1+vnew/vnew(3)*(endplane-p1(3));
  zplot=[zplot;p0(3),p1(3),p2(3),p3(3)]; % Don't pre-allocate these arrays
  xplot=[xplot;p0(1),p1(1),p2(1),p3(1)]; % That would limit the number of pts.
end;

Plot the complete raytrace

fig1=figure;plot(zplot',xplot');hold on;plot(zplot',-xplot');
plot(r-sqrt(r^2-((-1.1:0.001:1.1)*hmax).^2),(-1.1:.001:1.1)*hmax,'k');
plot(zimage,0,'ko');
axis([zobject,zimage,-hmax,hmax]*1.2);
%arrow([zobject,0],[zobject,0.5]);
%arrow([zimage,0],[zimage,-0.5/n]);
hold off;
xlabel('z, Axial Position');ylabel('x, Height');

Expand the region near the image, and show some dimensions

% Locate where the outer ray crosses the axis
zh=zplot(end,2)+(0-xplot(end,2))/(xplot(end,4)-xplot(end,2))*...
   (zplot(end,4)-zplot(end,2));

fig2=figure;plot(zplot',xplot');hold on;plot(zplot',-xplot');
plot(zimage,0,'ko'); % plot the paraxial image point
plot(zh,0,'ko');     % plot where the outer ray crosses the axis
dimheight=0.15; % set height of the dimension line for delta z
plot(zh*[1,1],[0,dimheight],'k-'); % vertical line for dimension
plot(zimage,dimheight,'k>');plot(zh,dimheight,'k<'); % arrowheads
plot([zh,zimage],dimheight*[1,1],'k-'); % dimension line
plot(zimage,-abs(xplot(end,3)),'kv'); % arrowheads for delta x
plot(zimage, abs(xplot(end,3)),'k^');
plot(zimage*[1,1],abs(xplot(end,3))*[-1,1],'k-'); % dimension delta x
hold off;
axis([8,10.2,-0.32,0.32]);
xlabel('z, Axial Position');ylabel('x, Height');