Optical bench

Lamps, prisms, lenses, mirrors, beam splitters and a grating on a table, seen from above. Every ray carries one wavelength drawn from its lamp's real spectrum, so white light fans into a rainbow and a sodium lamp stays one orange line. Drag things around, rotate them with the round handle, and add more from the toolbar. The spectra are the ones from the spectroscopy playground.

Scene
Add
Exposure
Rays per frame

How it works

Each frame, every light source sends out a few hundred rays. A ray's wavelength is drawn at random in proportion to the lamp's spectrum, so a hydrogen tube sends mostly red Hα rays and some blue-green Hβ, while a bulb sends a smooth mix weighted toward red. The ray then travels in straight lines until it meets something:

The picture builds up frame after frame: each ray adds its colour along its path (CIE colour matching), so where many rays overlap you see the mixture. That is why crossing beams of red and green make yellow, and why the dispersed fan from a prism turns white again where its colours overlap.

Things to try

Keys: drag to move, drag the round handle to rotate (hold Shift to snap to 15°), drag empty space to pan, scroll to zoom. With an element selected: arrow keys move it (Shift = 10 mm), Q/E rotate it (Shift = 15°), D duplicates and Delete removes it, and Tab on the bench cycles through the elements.

What is real and what is simplified

  • Real: refraction with measured dispersion (Sellmeier coefficients for BK7, F2, SF11, fused silica and diamond, and a Cauchy fit for water), unpolarised Fresnel reflection, total internal reflection, the grating equation, exact spherical lens surfaces (so spherical aberration and chromatic aberration both appear), and the lamp spectra.
  • Two-dimensional: this is a slice through the table. Lenses behave like cylinder lenses, the raindrop like a glass rod, and the gem like a cross-section of a brilliant cut. Angles and focal lengths in the slice are the same as in 3D, but brightness falls off as 1/r rather than 1/r².
  • Rays, not waves: no interference and no diffraction blur. The beam splitter scene shows the geometry of a Michelson interferometer but not its fringes, and the grating uses fixed, illustrative order efficiencies. Polarisation is not tracked: each reflection uses the unpolarised average.
  • Lamp spectra are the hand-built models from the spectroscopy playground: the right line positions and rough strengths, not measured spectra. Only 380–780 nm is traced, because that is the light you can see.