diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-07-11 23:00:08 -0400 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2011-07-11 23:00:08 -0400 |
commit | 1e75e07c2a1bf933733f342f68e80d7fd1b422fd (patch) | |
tree | 3921b36456935b1ba9f4bcc0f66e2265ced5aa75 /fresnel_reflection.m | |
parent | 80f6d6a223ee96d93d64baec3f3a5ab2329ed763 (diff) | |
download | wgmr-1e75e07c2a1bf933733f342f68e80d7fd1b422fd.tar.gz wgmr-1e75e07c2a1bf933733f342f68e80d7fd1b422fd.zip |
Fresnel equation vectorized with respect to incident angle
Diffstat (limited to 'fresnel_reflection.m')
-rw-r--r-- | fresnel_reflection.m | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/fresnel_reflection.m b/fresnel_reflection.m index 0e6dfdc..347d60b 100644 --- a/fresnel_reflection.m +++ b/fresnel_reflection.m @@ -1,27 +1,28 @@ function [R, theta_t] = fresnel_reflection(n1, n2, theta_i) %% calculates intensity reflection coefficient for s and p polarizations %% for light travelling from material with index of refraction n1 to material with n2 -%% theta_i - incident angle in medium 1 with respect to normal +%% theta_i - incident angle in medium 1 with respect to normal, could be a vector %% R - coefficients of reflection array [Rs, Rp] %% theta_t - transmitted/refracted angle in medium 2 with respect to normal + if ( size(theta_i)(1) != 1) + error('theta_i must be a vector or scalar'); + end + %% see http://en.wikipedia.org/wiki/Fresnel_equations %% refraction angle or angle of transmitted beam with respect to normal sin_theta_t=n1/n2*sin(theta_i); + %% special cases: total internal reflection + indx = (abs(sin_theta_t) >= 1); + sin_theta_t( indx ) = sign( sin_theta_t(indx) ); - if ( abs(sin_theta_t) >= 1) - %% total internal reflection - R = [1, 1]; - theta_t=sign(theta_i)*pi/2; - return; - end theta_t = asin(sin_theta_t); % angle of refraction or transmitted beam cos_theta_t = cos( theta_t ); cos_theta_i = cos( theta_i ); - Rs = ( ( n1*cos_theta_i - n2*cos_theta_t ) / ( n1*cos_theta_i + n2*cos_theta_t ) ).^2; - Rp = ( ( n1*cos_theta_t - n2*cos_theta_i ) / ( n1*cos_theta_t + n2*cos_theta_i ) ).^2; - R = [Rs,Rp]; + Rs = ( ( n1*cos_theta_i - n2*cos_theta_t ) ./ ( n1*cos_theta_i + n2*cos_theta_t ) ).^2; + Rp = ( ( n1*cos_theta_t - n2*cos_theta_i ) ./ ( n1*cos_theta_t + n2*cos_theta_i ) ).^2; + R = [Rs; Rp]; end |