loading...
running...
How to use
Choose a preset or build your own element: a lens from refractive index and surface radii, or a mirror. Drag the orange object arrow along the axis (or use the object-distance slider) and watch the three principal rays and the fan of rays; the cyan arrow is the image (dashed when virtual). The small panel shows what a screen at the focus would display, blurred when the screen is out of focus or the aberration is large. Try: (1) Projector then Magnifier to cross do = f; (2) Spherical aberration, then drag the screen away from the image with Follow off; (3) Add a second lens for a telescope; (4) Compare R1/R2 shapes with the same f. Drag to orbit, wheel to zoom. Space pauses.
The bench rail, carriages, lamp, lens holders, mirror mount and screen were modelled and baked in Blender; Three.js r160 builds the glass lens from the lensmaker radii and draws the rays from the same model as the 2D lab.
The science
All distances are in centimetres along the optical axis; light travels left to right and the first element sits at x = 0. In the paraxial (small-angle) approximation every ray is described by its height y and slope θ = dy/ds, and each element changes the slope only:
thin lens or mirror: θ' = θ - y / f, free flight: y' = y + θ s
Tracing two rays from the tip of the object and finding where they meet gives the image; for one element this reproduces the Gaussian lens equation and the magnification:
1/f = 1/do + 1/di, m = hi/ho = -di/do, x x' = f² (Newton)
di > 0 is a real image (rays really meet, a screen shows it, usually inverted); di < 0 is a virtual image (rays only appear to diverge from it, seen through the lens, upright). Three rays are drawn: parallel to the axis (leaves through the far focus), through the lens centre (undeviated) and through the near focus (leaves parallel).
Lens from glass. The thin-lens lensmaker's equation gives f from the refractive index and the two surface radii (signed; a radius of 120 or more is treated as a flat face):
1/f = (n - 1) (1/R1 - 1/R2)
Mirror. A spherical mirror of radius R has f = R/2 (concave positive). The reflection is simulated by unfolding it: the same slope update holds with the ray travelling back the other way. Two lenses separated by s combine as 1/f = 1/f1 + 1/f2 - s/(f1 f2); with s = f1 + f2 the pair is afocal (a telescope) with angular magnification -f1/f2.
Spherical aberration is added as an empirical third-order term: θ' = θ - (y/f)(1 + A (y/a)²) where a is the aperture radius. A marginal ray (y = a) parallel to the axis then crosses the axis at f/(1 + A), so the focus is smeared along the axis and the RMS blur of the spot on the screen has a minimum (the circle of least confusion) in front of the paraxial focus. This is a model of the effect, not a ray trace through real spherical surfaces; other aberrations (coma, astigmatism, chromatic dispersion) are not modelled.
Checks. (1) the image distance from two traced rays equals the lens equation, (2) the traced magnification equals -di/do, (3) Newton's x x' = f² at another object distance, (4) lensmaker f equals the reciprocal of the sum of the two surface powers, (5) marginal-ray focus f/(1 + A), (6) the concave mirror equation (R = 40, do = 30 gives di = 60 on the object side).
Simplifications. Thin elements (no thickness, principal planes coincide), monochromatic light, paraxial optics with the aberration model above, ideal mirror reflectivity, no diffraction or vignetting.