function [ras,rap,tas,tap]=fresnel(thetad,n);
%
%  FRESNEL.M computes Fresnel Reflection and Transmission
%  by Chuck DiMarzio
%     Northeastern University
%     September, 2001
%     Based on FORTRAN code by C. D. and Mike Healy, 1991
%
%   [ras,rap,tas,tap]=fresnel(theta,n);
%
%   where ras,rap,tas,tap are Reflection and Transmission
%         coeffcients for Amplitude for S and P polarization.
%   Input theta is in degrees, n is index of refracton, which may
%         be complex.
%
theta=thetad*pi/180;
%     amplitude reflection coefficient s polarized
ras=(cos(theta)-sqrt(n.^2-(sin(theta)).^2))./...
       (cos(theta)+sqrt(n.^2-(sin(theta)).^2));
%     amplitude reflection coefficient p polarized
rap=-( sqrt(n.^2-(sin(theta)).^2) -n.^2.*cos(theta) )./...
      ( sqrt(n.^2-(sin(theta)).^2) +n.^2.*cos(theta) );
%     amplitude transmission coefficient s polarized
tas=1.+ras;
%     amplitude transmission coefficient p polarized
tap=(1.+rap)./n;

