function [rs,rp] = amprc(n,k,theta)
%
% [rs,rp] = amprc(n,k,theta)
%
% calculates the amplitude reflection coefficients rs and rp of light
% incident from air with a polar angle of incidence theta on an optical 
% medium with complex refractive index n+i*k using Fresnel's equations.
%
% Input:    n     - refractive index (of reflecting medium)
%           k     - extinction coefficient (of reflecting medium)
%           theta - angle of incidence (with respect to surface normal)
%
% Output:   rs    - s-polarized coefficient
%           rp    - p-polarized coefficient
%
% Last updated: 2009-02-24 (David Bergström)
%

rs = (cos(theta) - sqrt((n+1i*k).^2-sin(theta)^2))./(cos(theta) + sqrt((n+1i*k).^2 - sin(theta)^2));
rp = ((n+1i*k).^2.*cos(theta) - sqrt((n+1i*k).^2-sin(theta)^2))./((n+1i*k).^2*cos(theta) + sqrt((n+1i*k).^2-sin(theta)^2));
