def refraction_plane(k_vec, n_vec, n1, n2):
'''
k_vec: the directional vector of the incidental ray
n_vec: the normal vector of the incidental plane
n1, n2: the refractive indices
'''
s_vec, p_vec, sin_ins = incident_plane(k_vec, n_vec)
sin_ref = n1*sin_ins /n2 # sin(phi')
a_inc = np.arcsin(sin_ins)
a_ref = np.arcsin(sin_ref)
a_diff = a_inc-a_ref
kr_vec = np.cos(a_diff)*k_vec -np.sin(a_diff)*p_vec
if(kr_vec[2]>0):
print(a_diff, k_vec)
# next, let's calculate the reflectance
cos_inc = np.cos(a_inc)
cos_ref = np.cos(a_ref)
Rs = ((n1*cos_inc - n2*cos_ref)/(n1*cos_inc + n2*cos_ref))**2
Rp = ((n1*cos_ref - n2*cos_inc)/(n1*cos_ref + n2*cos_inc))**2
return kr_vec, Rs, Rp
# done with refraction_plane
评论列表
文章目录