Toolyard

Refraction and Total Internal Reflection Simulator

Equations in this simulation

n₁ sin θ₁ = n₂ sin θ₂
n₁Material the light starts in (n₁)the refractive index: how many times slower light travels there than in a vacuum
n₂Material it enters (n₂)at the chosen wavelength, so it changes a little with the color
θ₁Angle of incidence θ₁ (°)measured from the normal, the dashed line square to the surface, not from the surface
θ₂angle of refractionsmaller than θ₁ going into a denser material (the ray bends toward the normal), larger coming out of one

With the current values:

v = c ÷ n
vspeed of light in the second materialc = 299,792 km/s; the moving dots slow down by this factor, and the change of speed is what bends the ray

With the current values:

sin θ_c = n₂ ÷ n₁
θ_ccritical angleonly exists going from a denser to a less dense material (n₁ larger than n₂); past it no light gets through and all of it reflects

With the current values:

tan θ_B = n₂ ÷ n₁
θ_BBrewster's anglelight polarized in the plane of incidence is not reflected at all here, so the reflection is fully polarized; polarizing sunglasses use this

With the current values:

R = ½ (r_s² + r_p²), r_s = (n₁ cos θ₁ − n₂ cos θ₂) ÷ (n₁ cos θ₁ + n₂ cos θ₂), r_p = (n₂ cos θ₁ − n₁ cos θ₂) ÷ (n₂ cos θ₁ + n₁ cos θ₂)
Rfraction of the light reflectedthe Fresnel equations, for unpolarized light; the rest, T = 1 − R, goes through. The chart plots them against the angle

With the current values:

n(λ) = A + B ÷ λ²
λWavelength λ (nm)Cauchy's formula: violet light sees a larger index than red, so it bends more, which is why a prism makes a spectrum

With the current values:

n₂ ÷ n₁ = sin((A + δ_min) ÷ 2) ÷ sin(A ÷ 2)
APrism apex angle A (°)the angle at the top of the prism
δdeviationhow far the beam is turned from its original direction; it is smallest, δ_min, when the ray crosses the prism symmetrically

With the current values:

NA = √(n₂² − n₁²) = n₁ sin θ_max
θ_maxacceptance angle of the fiberlight entering the end of the fiber at more than this from its axis hits the side at less than the critical angle and leaks out

With the current values:

How to use the refraction simulator

  1. Pick the material the light starts in and the one it enters, and set the angle of incidence. The beam bends at the boundary by Snell's law, a faint reflected beam goes back, and the white dots show the light slowing down in the denser material. The dashed line is the normal, which all the angles are measured from.
  2. Start in water, glass or diamond and enter air, then raise the angle. The refracted beam swings toward the surface and grows fainter, and past the critical angle it vanishes: all the light reflects. Tick Sweep the angle to watch it happen, and follow the reflected share on the chart, which also marks Brewster's angle, where light polarized in the plane of incidence is not reflected at all.
  3. Switch to the prism and tick White light to split a beam into its colors, or to the optical fiber to see light trapped by total internal reflection and leaking out when it enters at too steep an angle. For lenses and mirrors, the Lens and Mirror Simulator draws ray diagrams.

Frequently asked questions

What is Snell's law?

n₁ sin θ₁ = n₂ sin θ₂: the refractive index times the sine of the angle from the normal is the same on both sides of a boundary. The refractive index n is how many times slower light travels in the material than in a vacuum, 1.33 for water and about 1.5 for glass, so light entering glass from air bends toward the normal.

What is the critical angle?

The angle of incidence beyond which light cannot leave a denser material: sin θ_c = n₂ ÷ n₁. It is 48.6° from water into air, about 41° from glass and 24.4° from diamond, whose small critical angle traps light inside a cut stone and makes it sparkle. Past it, all the light reflects: total internal reflection.

Why does a prism split white light?

The refractive index of glass is slightly higher for violet light than for red (dispersion), so violet bends more at each face. In crown glass the index runs from about 1.531 at 400 nm to 1.513 at 700 nm, enough to spread a 60° prism's output over about 2°. The simulation uses Cauchy's formula n = A + B ÷ λ² for each material.

How do optical fibers carry light?

By total internal reflection: light travels along a glass core surrounded by material of lower index and hits the side at more than the critical angle every time, so none escapes. Light must enter within the acceptance angle, set by the numerical aperture NA = √(n_core² − n_clad²). Real fibers have a cladding only about 1% lower in index than the core, giving acceptance angles of about 12°.

It says WebGL is turned off.

The 3D view needs WebGL, which every current browser has. It can be switched off by hardware acceleration being disabled in the browser settings, or by a very old graphics driver. Turn hardware acceleration on, or try another browser.

Is anything uploaded?

No. The simulation is drawn by your own browser with WebGL; nothing is sent anywhere, and it keeps working offline once the page has loaded.

More science simulations

Related calculators and tools

Guides