The physics
Light is a wave. Its source sets the frequency f. In a medium of refractive index μ, light slows to c/μ. So its wavelength shrinks by μ too.
v = c / μ λ = λ₀ / μ
λ₁ μ₁ = λ₂ μ₂
Huygens: every point on a wavefront sends out a wavelet. The surface that touches all the wavelets is the new front.
new radius = old radius + v t
A small bulb makes spheres, so its light fades as 1/r². A long tube light makes cylinders, so its light fades as 1/r. Far sunlight makes planes, so it does not fade.
At a boundary, the wavelets inside grow μ times slower. The new front bends, and sin i = μ sin r follows.
μ₁ sin θ₁ = μ₂ sin θ₂
Optical path is μ × distance. Where one side of a front travels more optical path, that side lags. So a wedge or a graded slab tilts the front.
wedge: δ = (μ − 1) A
slab: sin θ = (μ₂ − μ₁) d / h