Snell's Law Simulation

by annebell in Workshop > Science

836 Views, 2 Favorites, 0 Comments

Snell's Law Simulation

Screenshot 2022-05-06 17.35.27.png
Screenshot 2022-05-06 17.35.22.png

We were challenged to create a simulation that demonstrated Snell's Law in order to better understand the reflection and refraction of light. By developing a strong understanding of the scientific concept, Snell's Law, we were able to apply and input this key information into our simulation.

The Basics

Light absorption, reflection, and transmission.png

When light hits the surface of an object, there are three possible outcomes. The light will either be absorbed, reflected, or transmitted through the object. Absorption refers to when the energy in the light is absorbed by the object. This often causes a change in the object Reflection is when the light bounces off the surface of the object. Light transmitted through an object goes through it without causing any changes. However, if the light is transmitted through an object with a different density, something special occurs. The light is refracted. Snell's Law gives scientists the rules needed to determine the angle of refraction for any given angle of incidence.

Understanding Snell's Law

SCN_20220506_105257.jpg
Screenshot 2022-05-06 17.19.35.png

n1 is the initial index. This measures how dense the material is. Often, this is air. The index of refraction for air is always 1.

sinΘ1 can be found by finding the sine of the angle of incidence. The sine function will be explained a bit later.

n2 is the refracted index. It measures the density of the second medium. For water, this is 1.33. For glass, this is 1.49.

Θ2 is the variable we are trying to solve for. Therefore, we have rearranged the equation to have sinΘ2 on one side.

sinΘ2= n1sinΘ1/n2

Note: Both sides of the equation should be multiplied by inverse sine to get Θ2 on its own.

Θ2= asin (n1sinΘ1/n2)

Explanation of the Sine Function

Screenshot 2022-05-06 17.38.54.png
Screenshot 2022-05-06 17.38.45.png
Screenshot 2022-05-06 17.38.35.png

To use the sine function, you need your reference angle, the side opposite of your reference angle, and the hypotenuse of the right triangle.

Sin θ = opposite / hypotenuse

In the picture, we can see how there are right triangles in the graph. To find the value of θ1, we use the opposite side (the side that the angle opens up to) and divide it by the hypotenuse of the right triangle. Using the other triangle, we can do the same to find θ2.

Setting Up Scratch

Air to Water Background.png
Air to Glass Background.png
Sprite Creation.png
Screenshot 2022-05-06 11.51.02.png

Before starting the code, there are some things that need to be set up.

We started by creating the backgrounds. Our simulation demonstrates the refraction that occurs from air to water and air to glass. Therefore, we have created two backgrounds. Please note that anything placed in the backgrounds cannot be changed or moved by the code.

Then, we created the sprites. These can and should be the things that are changed by the code. We created a ray of incidence, a reflected ray, and a refracted ray.

After that, we created the variables. Variables are useful because their values can be changed. We created an Angle of Incidence variable. We clicked the checkmark to make it appear on our simulation. Then, we changed it to a slider to allow the user to change the value of the angle. The second variable we made is called the refracted index. This variable is the same as n2 in Snell's Law. It will help the code find the angle of refraction.

Coding the Rays

Ray of Incidence Code.png
Reflected Ray Code.png
Final Code for Refracted Ray.png

The incident ray is the ray of light that travels from the light source, whether that be the sun, laser, etc. The angle of incidence is where the incident ray first hits the water; this angle is called theta 1 (Θ). We set limits for the variable as its values could only be 1-90. The dotted line that continues into the 4th quadrant represents the path the light would have travelled if the medium didn't change.

When light rays hit the surface of an object, often some of the light is reflected off the object. The code for the line of reflection is almost the same as the code for the incident ray. The only difference is that the line is reflected across the y-axis.

The refracted ray was the most difficult to code. We used Snell's Law (solved for Θ2) to help the simulation determine which direction the ray should point.

Switching Between Water and Glass

Screenshot 2022-05-06 11.51.14.png

Although figuring out how to switch between the backgrounds was easy enough, we encountered another problem. We could not figure out how to change the refracted index within the code. Initially, we did not even have it as a variable. However, upon discovering that we could make it a variable, things fell into place. We had our code set the value of the variable when the background was changed.

Our Snell's Law Simulation

Our Snell's Law Simulation

Summary

Screenshot 2022-05-06 17.14.25.png

Despite the difficulties we encountered while coding, that was not the hardest part of this assignment. The most difficult part, which we can all agree on, was understanding Snell's Law. At the beginning of the project, most of us did not even know what the sine function did. But now, at the other end of this, we have all become experts of the reflection and refraction of light.

Works Cited

test-case-sources.png

Works Cited

The Editors of Encyclopedia Britannica. “Snell's law | Definition, Formula, & Facts | Britannica.” Encyclopedia Britannica, 29 April 2021, https://www.britannica.com/science/Snells-law. Accessed 6 May 2022.

Khan, Sal. “Refraction and Snell's law (video).” Khan Academy, 8 December 2010, https://www.khanacademy.org/science/physics/geome... Accessed 6 May 2022.

The Physics Classroom. “Physics Tutorial: Snell's Law of Refraction.” The Physics Classroom, https://www.khanacademy.org/science/physics/geome... Accessed 6 May 2022.

Stark, Glenn. “light - Reflection and refraction | Britannica.” Encyclopedia Britannica, 1 December 2021, https://www.khanacademy.org/science/physics/geome... Accessed 6 May 2022.