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
Problem Comments
-
4 Comments
The function only has a single (undefined) input in the test suite instead of n_in and n_out.
Anyone else here a fan of The Little Mermaid?
Thanks Rahul. Made changes to the test suite. Sorry !!
James, I've started humming the song after reading the title...
Solution Comments
Show commentsProblem Recent Solvers51
Suggested Problems
-
Find the longest sequence of 1's in a binary sequence.
6240 Solvers
-
1170 Solvers
-
619 Solvers
-
Determine the number of odd integers in a vector
732 Solvers
-
349 Solvers
More from this Author9
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!