SNELLWIN Demonstration of rays in Snell's window
by Chuck DiMarzio Northeastern University March 2010
!! 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.
theta=[(20:20:40),48,(50:20:70)]; % Choose angles to display theta=[-fliplr(theta),0,theta]; x0=zeros(size(theta)); % Starting point is 10 meters down y0=-10*ones(size(theta)); y1=zeros(size(theta)); % Surface is at y=0; x1=(y1-y0).*tand(theta); % x location on surface thetap=asind(1.33*sind(theta)); % compute theta' from Snell's law r=30; % Radius of rays to trace from surface into air x2=x1+r*sind(theta); % Assume reflection first y2=y1-r*cosd(theta); % y is below the surface test=(imag(thetap)==0); % If thetap is real, then no total internal % reflection x2(test)=x1(test)+r*sind(thetap(test)); y2(test)=y1(test)+r*cosd(thetap(test)); fig1=figure;plot([x0;x1;x2],[y0;y1;y2],'-',40*[-1,1],[0,0],'-'); axis(40*[-1,1,-1,1]);axis square;axis off;
