Cody

Problem 44070. Under the sea: Snell's law & total internal reflection

https://en.wikipedia.org/wiki/Snell's_law

When a light travels from one medium to another medium, depending on the refractive index, the light will bend with a certain angle. For certain combination of materials, it might be that light cannot escape one medium at all from a certain angle (greater than critical angle). It is called total internal reflection. If you point a flashlight from "under the sea" the light won't leave the water at all.

For given refractive indices, find critical angle where total internal reflection happens. If total internal reflection does not happen for any angle, then return "-1".

Example1: n_in = 1.333, n_out = 1, theta_crit = 48.6 degrees; Example2: n_out = 1, n_in = 1.333, theta_crit = -1 (total internal reflection does not occur, if you are in the air, and beaming light at the water.)

Input of function: n_in, n_out (refractive index, positive) Output: critical angle (rounded to nearest integer), if total internal reflection occurs. Else return -1.

Solution Stats

42.86% Correct | 57.14% Incorrect
Last Solution submitted on Oct 14, 2019

Problem Comments


Problem Recent Solvers23

Problem Tags