Drag the flashlight around to change its position and angle. Use the sliders to control the index of refraction in the two regions.
Snell's Law describes how the angle of refraction depends on the change in index of refraction between two materials. The angles of the raw follow the well known law $$n_1\sin\theta_1=n_2\sin\theta_2$$. This simulation shows the path a light ray would take based on the index of refraction of the two materials. Total internal reflection also occurs when the angle of incidence is too small.
Link to stand-alone sim: Here is a link to view the sim on its own, with no distractions.