Light slows down in glass. That single fact, plus a bit of geometry, explains lenses, prisms, rainbows and the sparkle of a diamond.
Refractive index
The refractive index n of a material is how much slower light travels inside it than in vacuum:
n = c / v — light at 532 nm inside BK7 (n = 1.519) travels at about 197,000 km/s instead of 299,792 km/s.Water is about 1.333, ordinary crown glass 1.52, dense flint 1.785, diamond 2.417.
Snell's law
When light crosses from one material into another at an angle, it changes direction. The rule, measured from the line perpendicular to the surface (the normal):
n₁ · sin θ₁ = n₂ · sin θ₂Going into a denser material (n₂ > n₁) bends the ray toward the normal; coming out again bends it away.
Photonica applies exactly this at every surface, for every wavelength, every frame. You can watch it happen: Ctrl+click any beam to open the ray inspector, which lists the incidence and exit angle at each surface along with the indices used.
Why colours separate
The refractive index is not one number — it depends on wavelength. Blue light is slowed more than red, so it bends more. That dependence is called dispersion, and it is the reason a prism makes a rainbow.
Photonica stores dispersion the way glass manufacturers publish it, as Sellmeier coefficients:
n²(λ) = 1 + Σ Bᵢ λ² / (λ² − Cᵢ)λ in micrometres. B and C are measured constants, six numbers per glass. This is the same formula running live on the Photonica home page.
The Abbe number
One number summarises how strongly a glass disperses:
V = (nd − 1) / (nF − nC)High V (crown glass, ~64) disperses weakly. Low V (flint glass, ~25) disperses strongly. The Build panel shows V for whatever glass you select.
Prisms
A prism bends light twice — once going in, once coming out — and both bends push the same way, so the total deviation is large. As you rotate a prism, the deviation falls to a minimum and then rises again. At that minimum the light passes symmetrically through the prism, and the angle is:
δmin = 2 · asin( n · sin(A/2) ) − AA is the apex angle. For a 60° BK7 prism at 587.6 nm this gives 38.6°, which is what Photonica measures to within 0.04°.
For small apex angles the formula simplifies to the one you may have met at school, δ ≈ (n − 1)·A.
Demo 3: white light dispersed by a prism. Each colour leaves at its own angle because each sees a slightly different refractive index.