Optics simulator: prisms, lenses and gratings

Three optics benches built from the real equations. Split white light into a spectrum with a glass prism, move an object along an optical bench to see real and virtual images form, and fan light into rainbow orders with a diffraction grating whose line density you control.

This interactive simulation runs in your browser with WebGL. Free, no account needed.

What you can explore

Prism

Forty-eight wavelengths pass through a glass prism with Cauchy dispersion, so violet bends more than red and a spectrum spreads across the screen. Steepen the prism to push rays past the critical angle into total internal reflection.

Lens lab

An optical bench with a converging lens. Move the object and the three principal rays and the full light fan trace out the image using 1/f = 1/u + 1/v. Inside the focal length the rays diverge and dashed lines find the virtual, upright, magnified image: the magnifying glass.

Diffraction grating

A white beam hits a ruled grating and each order fans out as a continuous rainbow onto a curved screen. Change the lines per millimetre and every order spreads or narrows, following d sin θ = mλ.

Key equations

  • n₁ sin θ₁ = n₂ sin θ₂
  • 1/f = 1/u + 1/v
  • m = −v/u
  • d sin θ = mλ

Curriculum

AQA A-level physics 3.3.2, IB Physics C.2 and C.3.

Common questions

When is the image from a converging lens virtual?

When the object is closer to the lens than the focal length. The rays leave the lens diverging, so they only appear to come from a point behind the object, giving an upright, magnified image.

Why does a prism split white light?

Glass has a slightly higher refractive index for shorter wavelengths, so violet light bends more than red at each surface and the colours separate.

More physics simulations