A simulator for light path in a medium with spatially varying refractive index.
n(x,y) =
This web simulates the path of light from one or more laser in a custom medium. The simulation is based on Snell's Law, so reflection and intensity variation are not accounted for. In addition, the simulation is limited in a 2D space with a rectangular medium.
In this mockup version, the simulation doesn't work yet. The visualization given is just a placeholder.
This application has two inputs:
This application has two outputs:
The rectangle is split into a grid of cells. In this grid, the laser is treated as an object that occupies a single cell and have a direction of travel. In each iteration, the object has a probability of going either one step along the x axis or y axis with the probability proportional to the direction's components. Everytime the object moves by one cell, Snell's Law is applied. Using the the target and origin cell's index of refraction as well as the initial direction, the new direction after refraction is calculated. The interface of the refraction is taken to be the border between cells.
The simulation is run until all lasers exit the medium or a maximum number of iterations is reached. The position of each laser is tracked throughout the simulation and displayed on the canvas.