blob: fd9ee0283a6f572e61ac5914c07a02adee7ee41b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
% fresneliso.m - Fresnel reflection coefficients for isotropic media with either indices _or_ lambda as vectors
%
% Usage: [rs,rp] = fresnel(na,nb,theta)
%
% na,nb = refractive indices of left and right media. May be vectors if lambda is not.
% theta = incident angle(s) in degrees. May be a vector if na and nb are vectors.
% rs,rp = reflection coefficients for p and s polarizations
%
% Modified by Andri M. Gretarsson from fresnel.m written by Orfanidi. August 2008.
function [rs,rp] = fresnel(na,nb,theta)
if nargin==0, help fresnel; return; end
if length(na)==1
na=ones(size(nb))*na;
elseif length(nb)==1
nb=ones(size(na));
end
theta = pi*theta/180;
if length(nb) == 1
Na = 1./sqrt(cos(theta).^2/na^2 + sin(theta).^2/na^2);
xe = (na*sin(theta)).^2; % used for s-pol
xm = (Na.*sin(theta)).^2; % used for p-pol
rs = (na*cos(theta) - sqrt(nb^2 - xe)) ./ ...
(na*cos(theta) + sqrt(nb^2 - xe));
if na==nb,
rp = (na - nb) / (na + nb) * ones(1,length(theta));
else
rp = (na*na * sqrt(nb^2 - xm) - nb*nb * sqrt(na^2 - xm)) ./ ...
(na*na * sqrt(nb^2 - xm) + nb*nb * sqrt(na^2 - xm));
end
elseif length(theta) == 1
Na = 1./sqrt(cos(theta)^2./na.^2 + sin(theta)^2./na.^2);
xe = (na*sin(theta)).^2; % used for s-pol
xm = (Na*sin(theta)).^2; % used for p-pol
rs = (na*cos(theta) - sqrt(nb.^2 - xe)) ./ ...
(na*cos(theta) + sqrt(nb.^2 - xe));
if na==nb,
rp = (na - nb) ./ (na + nb);
else
rp = (na.*na .* sqrt(nb.^2 - xm) - nb.*nb .* sqrt(na.^2 - xm)) ./ ...
(na.*na .* sqrt(nb.^2 - xm) + nb.*nb .* sqrt(na.^2 - xm));
end
else
error('Either na and nb must have length 1 _or_ theta must have length 1.');
end
|