LENS2 Demonstration of various lens equations for Chapter 2
SYNTAX: lens2;
by Chuck DiMarzio Northesastern University December 2008
!! 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
Radii of curvature for given focal length
ra=(-25:0.1:25); % Radius axis n=1.5; fa=[-10,10]; % Focal lengths [f,r1]=meshgrid(fa,ra); % r1 is the phorizontal axis r2=1./(1./r1-1./(f*(n-1))); % Calculate r2 ax=25; % Axis size fig1=figure(1); plot(ra,r2(:,1),'--',ra,r2(:,2),'-',...; 0.7*[ax,-ax],0.7*[-ax,ax],'k-',0.7*[ax,-ax],0.7*[ax,-ax],'k-',... [0,0],[-ax,ax],'k-',[-ax,ax],[0,0],'k-');grid on; axis equal;axis(ax*[-1,1,-1,1]); xlabel('r_1, Radius of First Surface'); ylabel('r_2, Radius of Second Surface'); hold on; for r1p=[-0.8,-0.25,0.25,0.8]*ax; % Show the lens shapes on the plot for r2p=[-0.8,-0.25,0.25,0.8]*ax; [x,y,yedge]=lensshape(r1p,r2p,5,1); plot(r1p+x*ax/10/yedge,r2p+y*ax/10/yedge); end; end; hold off;


Plot using inverse radii
ax=1/4;f1=10;n=1.5; r1inv=ax*(-1:0.1:1); %f This is 1/r1 p1=(n-1)*r1inv; p2=1/f1-p1; r2inv=-p2/(n-1); fig2=figure(2); plot(r1inv,r2inv,'k-',... [-ax,ax],[-ax,ax],'k:'); hold on; f1=-10; p2=1/f1-p1; r2inv=-p2/(n-1); plot(r1inv,r2inv,'k--') axis equal;axis(ax*[-1,1,-1,1]);grid on; ha=gca;
Invert the labels on the graph
strInv = @(str) sprintf('%2d',floor(1/str2double(str))); ticLabel=get(ha,'XTickLabel'); newTicLabel = cell(length(ticLabel),1); for idx = 1:size(ticLabel,1) newTicLabel{idx}=strInv(ticLabel(idx,:)); end set(ha,'XTickLabel',newTicLabel); ticLabel=get(ha,'YTickLabel'); newTicLabel = cell(length(ticLabel),1); for idx = 1:size(ticLabel,1) newTicLabel{idx}=strInv(ticLabel(idx,:)); end set(ha,'YTickLabel',newTicLabel); xlabel('r_1, Radius of First Surface'); ylabel('r_2, Radius of Second Surface'); hold on; for px1=[-0.8,-0.4,0.001,0.4,0.8]*ax; % Px is the inverse of r for px2=[-0.8,-0.4,0.001,0.4,0.8]*ax; r1p=1/px1; r2p=-1/px2; [x,y,yedge]=lensshape(r1p,-r2p,5,1);plot(px1+x*ax/10/yedge,px2+y*ax/10/yedge); end; end; hold off;


Object and image distance for positive and negative lenses
ax=60; sa=-60:60; % Object distance fa=[-10,10]; % Two focal lengths [f,s]=meshgrid(fa,sa); sprime=1./(1./f-1./s); % Image distance fig3=figure(3); plot(sa,sprime(:,1),'--',sa,sprime(:,2),'-',... [0,0],[-ax,ax],'k-',[-ax,ax],[0,0],'k-');grid on; axis equal;axis(ax*[-1,1,-1,1]); xlabel('s, Object Distance'); ylabel('s'', Image Distance'); text(ax/3,ax/2,['Real Object,',char(10),'Real Image']); text(ax/3,-0.8*ax,['Real Object,',char(10),'Virtual Image']); text(-0.8*ax,ax/2,['Virtual Object,',char(10),'Real Image']); text(-0.8*ax,-0.8*ax,['Virtual Object,',char(10),'Virtual Image']);
