diff options
author | Eugeniy Mikhailov <evgmik@gmail.com> | 2013-01-16 14:27:10 -0500 |
---|---|---|
committer | Eugeniy Mikhailov <evgmik@gmail.com> | 2013-01-16 14:27:10 -0500 |
commit | 37d09478a8fca4e1229dcb1246c9f23f1f6118df (patch) | |
tree | 79e2d5f9179987b46b5b743c552c29f94ffb999e /beam_tracing/fresnel_reflection.m | |
parent | 28ef703f718ce7f540864ca8f9a301f8d7d3f3e0 (diff) | |
download | wgmr-37d09478a8fca4e1229dcb1246c9f23f1f6118df.tar.gz wgmr-37d09478a8fca4e1229dcb1246c9f23f1f6118df.zip |
move code to directory with speaking name
Diffstat (limited to 'beam_tracing/fresnel_reflection.m')
-rw-r--r-- | beam_tracing/fresnel_reflection.m | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/beam_tracing/fresnel_reflection.m b/beam_tracing/fresnel_reflection.m new file mode 100644 index 0000000..347d60b --- /dev/null +++ b/beam_tracing/fresnel_reflection.m @@ -0,0 +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, 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) ); + + + 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]; +end |