import numpy as np def fresnelReflection(n1, n2, thetaInc): # 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 np.size(thetaInc, axis=0) != 1: # error('thetaInc must be a vector or scalar') # see http://en.wikipedia.org/wiki/Fresnel_equations # refraction angle or angle of transmitted beam with respect to normal sinThetaTrans = n1 / n2 * np.sin(thetaInc) # special cases: total internal reflection if abs(sinThetaTrans) >= 1: sinThetaTrans = np.copysign(1, sinThetaTrans) thetaTrans = np.arcsin(sinThetaTrans) # angle of refraction cosThetaTrans = np.cos(thetaTrans) cosThetaInc = np.cos(thetaInc) Rs = ((n1 * cosThetaInc - n2 * cosThetaTrans) /\ (n1 * cosThetaInc + n2 * cosThetaTrans)) ** 2 Rp = ((n1 * cosThetaTrans - n2 * cosThetaInc) /\ (n1 * cosThetaTrans + n2 * cosThetaInc)) ** 2 R = np.array([[Rs], [Rp]]) return [R, thetaTrans]