Reflection and Refraction


In physics, we learn that reflection and refraction can be explained by light taking the shortest path between two points. I simulated this with a program I wrote in PowerShell Studio, which is an IDE for PowerShell.

1.PNG

It calculates the distance for each of a number of paths that lead from the source to the destination by bouncing off the mirror. The two angles are calculated from the path with the shortest distance. The angles are equal as predicted by the law of reflection.

For reflection, the shortest path is the fastest path because the light travels at a constant speed. In the case of refraction, the speed along the path will vary because the light travels in different materials. The path of the light is described by the law of refraction:

n_1sin(\theta_1)=n_2sin(\theta_2)

n is the refractive index of a material. It’s 1 for air and 1.5 for some types of glass. It indicates how much slower air is in that material compared to a vacuum.

In my setup, the light is refracted twice on its way to the destination. Both times, it follows the law of refraction. The program runs through a specified number of paths to find the one that takes the least time. Then it calculates the angles and n\cdot sin(\theta) The angles to compare for the law of refraction are 1:2 and 3:4. Those angles are when the light refracts. Here’s what a run of it looks like.

2

As we can see in the bottom two rows, n_1sin(\theta_1) \approx n_2sin(\theta_2) and n_2sin(\theta_3) \approx n_1sin(\theta_4) . Because it’s using more sines and arctangents than the reflection part, the program needs more iterations to have the values be close. Angles 1 and 4 are very close to each other. This is not a coincidence. As we saw before, from the law of refraction

n_1sin(\theta_1)=n_2sin(\theta_2) (1)

\theta_2=\theta_3 (2)

because they are alternate interior angles. Substituting into (1),

n_1sin(\theta_1)=n_2sin(\theta_3) (3)

By the law of refraction again,

n_2sin(\theta_3)=n_1sin(\theta_4) (4)

Substituting into (3),

n_1sin(\theta_1)=n_1sin(\theta_4) (5)

\theta_1=\theta_4

In other words, the light coming out of the glass will be going in the same direction as the light coming in. There’s your proof for the day.

Executable
PSF File
Code
The psf file has to be opened in PowerShell Studio, but the code is just a txt.

Leave a Reply

Your email address will not be published. Required fields are marked *