Skip to content
Advertisement

Snell’s Law not functioning

I am writing a program to calculate light refraction using snell’s law, however, when I run the program it prints -0.7076118148 rather than the correct value of 22

import numpy as np
theta_1 = 30
n1 = 1
n2 = 1.33
theta_2 = np.arcsin(n1 / n2 * np.sin(theta_1))
print(theta_2)

Advertisement

Answer

You’re using degrees instead of radians.
You’ll have to convert, e.g like this:

import numpy as np
theta_1 = 30;
n1 = 1
n2 = 1.33
theta_1_rad = np.radians(theta_1)
theta_2_rad = np.arcsin(n1 / n2 * np.sin(theta_1_rad))
theta_2 = np.degrees(theta_2_rad)
print(theta_2)

=> 22.082413194472252

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement