Ray Optics Bench, Explained

After reading this you can predict where a lens focuses light, work out at what angle a prism splits white light into colours, and check every ray the bench draws against Snell's law by hand.

What the bench does and one example to anchor it

Geometric optics treats light as straight rays that travel until they hit a surface, then bend or bounce. The bench draws those rays live. You place a source that fans out a beam, drop in lenses, mirrors and a prism, and drag things around while the rays redraw.

Here is the anchor example. Take a converging lens with focal length 100 pixels. Send in three rays parallel to the axis, spaced 20 pixels apart. All three cross the axis at a single point 100 pixels past the lens. That crossing is the focal point. Move the rays farther from the axis and they still meet there. That single fact, parallel rays converging to one point, is the whole reason a magnifying glass can burn paper.

The bench never uses wave physics for lenses and mirrors. It uses angles and straight lines. That keeps it fast and exact for the questions it answers, and useless for the questions it cannot answer. The next section draws that line clearly.

When to use ray optics and when it fails

Use ray optics when the objects are large compared to the wavelength of light. Visible light spans roughly 400 to 700 nanometres. A lens is centimetres wide, about 100000 times larger. At that scale, treating light as rays predicts focus points and image positions to within a fraction of a percent.

Ray optics fails when the aperture gets small. Send light through a slit only a few wavelengths wide and it spreads out in a diffraction pattern that no ray model produces. It also cannot show interference fringes, because rays carry no phase. For those effects you need the wave picture. The Wave Interference tool covers the double slit and ripple-tank fringes that this bench deliberately ignores.

A useful rule of thumb: if the smallest opening in your setup is wider than about 100 wavelengths (roughly 0.05 mm for visible light), ray optics is accurate. Below that, diffraction dominates and this bench will mislead you.

The two laws that govern every ray

Only two rules bend light on this bench. Reflection handles mirrors. Refraction, through Snell's law, handles lenses and the prism.

Reflection is the simpler one. The angle of the outgoing ray equals the angle of the incoming ray, both measured from the normal (the line perpendicular to the surface at the hit point).

\theta_r = \theta_i

Here \theta_i is the incident angle and \theta_r is the reflected angle. A ray hitting a flat mirror at 30 degrees from the normal leaves at 30 degrees on the other side of the normal.

Refraction is Snell's law. When light crosses from a medium of refractive index n_1 into one of index n_2, the angles obey:

n_1 \sin\theta_1 = n_2 \sin\theta_2

The refractive index n measures how much a medium slows light: n = 1 for vacuum, about 1.0003 for air, 1.33 for water, and 1.5 for common glass. Going into denser glass, n_2 \gt n_1, so \sin\theta_2 shrinks and the ray bends toward the normal. Leaving the glass it bends away. A lens is just two curved glass surfaces arranged so every parallel ray bends toward the same focal point.

Push \theta_1 large enough while leaving a dense medium and Snell's law demands \sin\theta_2 \gt 1, which is impossible. Past that critical angle the ray reflects entirely back inside. That is total internal reflection, and it is what traps light inside an optical fibre.

\theta_c = \arcsin\!\left(\frac{n_2}{n_1}\right)

Worked example: the default prism splitting white light

Dispersion through a glass prism

Load the demo. White light enters one face of a glass prism at an incident angle of 40 degrees from the normal. Glass disperses colour because its index depends on wavelength: take n = 1.513 for red and n = 1.528 for blue. Air is n_1 = 1.

  1. Red at the first face: \sin\theta_2 = \sin(40^\circ)/1.513 = 0.6428/1.513 = 0.4249, so \theta_2 = 25.15^\circ.
  2. Blue at the first face: \sin\theta_2 = 0.6428/1.528 = 0.4207, so \theta_2 = 24.89^\circ.
  3. Inside the glass the two colours already differ by 0.26^\circ. Small, but it grows.
  4. Each ray then crosses the second face, bending away from the normal, and the same index gap widens the split again. The total spread between red and blue exiting a 60 degree prism at this input works out to about 1.4 degrees.

That is why the fan you see is narrow near the prism and clearly separated a few hundred pixels downstream. The bench does this calculation once per colour band, so red rides on the outside of the exit fan and blue on the inside, matching a real prism.

The refracted angle falls as the index rises, so blue bends most. The gap is only about a quarter of a degree at the first face, then widens at the second.

Snell's law with air to glass (n_1 = 1, n_2 = 1.5): an incident angle of 30 degrees refracts to 19.47 degrees. Going the other way, glass to air, the critical angle is \arcsin(1/1.5) = 41.81^\circ; beyond it light reflects entirely.

Reading the rays: focus, image and dispersion

Three patterns tell you almost everything the bench shows.

Convergence to a point means a real focus. Parallel rays through a converging lens meet at the focal distance f. Rays diverging from a nearby object meet at the image distance v given by the thin-lens equation:

\frac{1}{v} = \frac{1}{f} - \frac{1}{u}

Here u is the object distance and f the focal length. With f = 100 and an object at u = 300 pixels, 1/v = 1/100 - 1/300 = 0.006667, so v = 150 pixels. The rays cross 150 pixels behind the lens. Move the object to u = 100 (right at the focal length) and 1/v = 0: the outgoing rays are parallel and never cross.

Divergence means no real focus. A diverging lens spreads parallel rays as if they came from a point in front of it. Trace them backward and they meet at a virtual focus.

A widening colour fan means dispersion, only ever from the prism. Lenses and mirrors on this bench treat all colours the same.

Common mistakes when reading the bench

Angles in optics are measured from the normal, not from the surface. A ray grazing a mirror at 10 degrees above the glass has an incident angle of 80 degrees, not 10. Mixing these up flips every prediction.

A second mistake is expecting total internal reflection when going into denser glass. It never happens that way. The critical angle only exists on the exit from dense to rare, where n_1 \gt n_2. With n_1 = 1.5 and n_2 = 1 the critical angle is 41.81 degrees; below it light exits, above it stays trapped.

A third mistake is reading the focal point as a physical dot. It is where the ray lines cross. With a real lens some rays miss it slightly (spherical aberration), and the bench may or may not model that. If your rays do not all meet at one point, check whether that is aberration by design or just rays that started too far off-axis for the thin-lens approximation to hold.

Finally, do not expect brightness or intensity. The bench draws ray geometry, not energy. Two rays crossing does not make a bright spot on this canvas the way it would on a screen.

Related tools

If the bending of light here interests you, two neighbours push further. Black Hole Lensing bends light by gravity instead of glass, so straight rays curve continuously around a mass. Wave Interference picks up exactly where ray optics stops, showing the fringes and diffraction that rays cannot represent.

For other physics sandboxes on the same canvas engine, try the chaotic Double Pendulum, the field-line drawing of Magnetic Field Lines, or the resonance shapes of Standing Waves on a String.

Frequently asked questions

Why does blue light bend more than red in the prism?

Glass has a slightly higher refractive index for shorter wavelengths. Using n = 1.528 for blue and n = 1.513 for red, Snell's law gives a smaller refracted angle for blue, so blue bends harder toward the normal. Across two prism faces the small gap builds into a visible spread of about 1.4 degrees.

What focal length gives the tightest focus?

A shorter focal length focuses closer to the lens and bends rays more sharply. A lens with f = 50 focuses parallel rays at 50 pixels; one with f = 200 focuses at 200. Neither is tighter in principle for ideal thin rays, but the short lens crowds the rays into a smaller region, so it looks sharper on screen.

Can I get total internal reflection with a lens?

Only at steep angles on the exit surface. For a normal lens the rays hit the second face close to the normal, well under the 41.81 degree critical angle for glass to air, so they pass through. Prisms exploit total internal reflection because their faces meet the rays at large angles.

Why do my parallel rays not meet at exactly one point?

Rays far from the axis violate the thin-lens (paraxial) approximation and cross slightly short of the ideal focus. That is spherical aberration, and it is real physics, not a bug. Keep rays within a few lens radii of the axis to see a clean single crossing.

Does this simulation run online or on my device?

Every ray is computed locally in your browser. Nothing is sent to a server, so the bench works offline once the page has loaded.