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.
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:
- Glass bends it by Snell's law, using that glass's refractive index at that wavelength (Sellmeier formulas). That is all dispersion is: blue sees a slightly higher index than red. A random draw with the Fresnel probability decides whether the ray reflects instead (about 4 % head-on, 100 % beyond the critical angle, which is total internal reflection).
- Mirrors reflect; a beam splitter reflects a set fraction of rays and lets the rest through.
- A grating sends each ray into one diffraction order, chosen at random, at the angle given by d·sin θ = m·λ.
- A screen catches rays and records where they land and their wavelengths, shown below the bench. An absorber or slit just stops them.
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
- Newton's prism: swap the sunlight for low-pressure sodium. The rainbow collapses to one line.
- Spectrometer: pick a different lamp in the spectrometer scene and read its barcode on the screen. Neon is a forest of red lines, and mercury gives a violet, blue, green and yellow set.
- Rainbow: zoom in on the raindrop. Light that bounces once inside comes back out about 42° from the incoming direction, red on the outside and violet on the inside.
- Achromat: zoom into the two foci. A single lens focuses blue closer than red. The crown-and-flint pair brings them together, which is why camera lenses are made of several glasses.
- Diamond: turn the gem slowly. Its high index traps light by total internal reflection, and its strong dispersion splits what escapes into "fire".
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.