A JavaSim simulation demonstrating how light is refracted and reflected by raindrops to form the optical phenomenon we all know and love: the rainbow.
When sunlight passes through raindrops, the total angle change after refracting, reflecting, and dispersing stops at a certain limit dependent on the wavelength of light.
For each ray of sunlight, it strikes the raindrop with an angle of incidence, .
According to Snell's law, when changing mediums from air to water or water to air, an angle of refraction can be calculated:
where is the refractive index, the ratio of the speed of light to the phase velocity of light in the medium.
Solving the geometry of the problem, we can see that the total deflection angle, , can be represented as a function of and :
or, solving for , simply as a function of :
For a certain refractive index (about 1.3 in this case), the graph from angles 0° to 90° looks like so:
This angle where varies slightly as changes (see this empirical data), causing bundles of certain wavelengths to group up at certain angles, generating the rainbow as a result of dispersion.
The current output of the simulation:
A zoomed in version of the bottom 6.5% of the outputted rays is visible in the bottom right.
RaindropRainbow is a JavaSim simulation. After installing JavaSim, place RaindropRainbow.jar into the JavaSim folder (located in your Documents folder by default).