Ø1"–Ø10" N-BK7 lenses (Ø3" default) on a dovetail rail · exact rays through real lens thickness · real images on a screen, virtual images on a probe plane
In short: A lamp shines through an arrow-shaped cut-out, and a glass lens bends that light to make a picture of the arrow. Four rays from the arrow's tip show how: the textbook "ray diagram", traced here through real 2-inch lenses on a real optics rail. When the light really comes together, a white screen catches a sharp, upside-down picture (a real image). When it spreads apart, nothing can catch it; only a see-through probe plane, which is not a real object, shows where your eye would see the picture (a virtual image).
Drag the light source, the lenses, the white screen or the dashed probe plane along the rail in the 3D view (or use the sliders). To turn a lens on its post, drag the blue ring on its carrier (or Shift-drag the lens, or use its slider); the traced rays and the screen image include the tilt, the paraxial numbers do not. Rays from the object tip: ■ parallel · ■ through the centre (nodal point) · ■ through the focal point · ■ to the lens edge. ■ toward the centre of curvature C of the first curved surface (it meets that surface square on, so it is not bent there; it bends only at the flat back face). Dashed grey lines are backward extensions: light never travels along them.
100 × 100 mm card. Only light that actually reaches it can form a picture: a real image.
Plots where the outgoing rays, or their backward extensions, cross this plane. It is how your eye or a camera "sees" a virtual image. 120 × 120 mm.
Try
The mirror faces the object and sends the light back. In mirror mode the screen catches only the returning light (in the lab, use a small card held off to the side, or tilt the mirror slightly so the image lands beside the object).
Ray plane (for the diagram rays and the 2D view)
Show
Every ray from the arrow tip that gets through the lens goes to the same image point (to within aberrations). Three of them are easy to draw, so textbooks use them: the ray parallel to the axis leaves through the back focal point F′; the ray aimed at the centre (strictly the front nodal point of a thick lens) leaves parallel to how it came in; the ray through the front focal point F leaves parallel to the axis. The fourth ray, to the edge of the lens, shows that the choice is only convenience.
Real image: the outgoing rays really cross. Light is there, so a screen placed there shows a sharp picture, upside down. Virtual image: the outgoing rays spread apart; only their backward extensions (dashed) cross. No light is at that place, so no screen can catch it, but your eye (or the probe plane) traces the rays back and sees the image there.
Why the real lens is not quite the textbook lens: the glass is thick (up to 12 mm here), so distances are measured from the principal planes H and H′, not the lens centre. The spherical surfaces bend edge rays a little too much (spherical aberration), so the best focus sits slightly in front of the paraxial image. Blue light focuses shorter than red (chromatic aberration), which you can see as coloured fringes on the screen with the white LED.
A ray-diagram trainer built on a realistic optics bench, for introductory physics (conceptual or algebra-based). It connects the textbook three-ray construction to what a student actually sees on a bench: - where the image forms and why; - real versus virtual images; - magnification and inversion; - why real thick lenses differ slightly from the thin-lens equation.
Each lens is drawn with its true thickness and surface shape. Any lens can be flipped or turned about the optical axis; gold ticks mark a cylinder's axis. - Idealized thin lens: a checkbox per lens swaps the real glass for the textbook lens: a zero-thickness plane with the same focal length that changes every ray's slope by exactly −h/f (no aberration, no colour). The ray through F then leaves exactly parallel and every ray from a point meets at one image point, so you can compare the textbook picture with the real thick lens. It has no surfaces, so no C is drawn for it. - Mirror mode: a concave (f = 100, 150, 250, 500 mm) or convex (f = −100, −250 mm) spherical mirror on the rail, facing the object. Rays reflect exactly off the true sphere (law of reflection at the local normal); C, F, the parallel, vertex, focal and through-C rays, real images caught on the screen and virtual images behind the mirror on the probe plane. The screen catches only the returning light (in the lab: a small card off to the side, or the mirror tilted slightly). Presets: object beyond C, object inside F (makeup mirror), convex mirror. - Ray toggles: a row of switches over the 3D view turns each diagram ray (and the full bundle) on or off, with "all off" and "all on". - Two ray planes: the diagram rays and the 2D view can be shown in the vertical (y) plane or the horizontal (x) plane. That is how you see astigmatism: each plane has its own focus, and the screen shows a line focus at each. - Moving things: drag the object, the lenses, the screen and the probe plane along the rail in 3D (or use the sliders). Carriers cannot pass through each other; the probe plane can, because it is not physical. - Turning a lens on its post: drag the blue ring on its carrier (or Shift-drag the lens, or use its slider), up to ±45°. The traced rays and the screen image include the tilt (you see coma and astigmatism appear); the paraxial readouts do not. - Ray-diagram rays, traced exactly through the glass: - parallel → through F′; - through the centre (nodal point) → undeviated direction; - through F → parallel; - to the lens edge; - toward the centre of curvature C of the first curved surface: it meets that surface at normal incidence, so it is not bent there, only at the flat back face. - Both faces get a C: C₁ for the front face, C₂ for the back face, marked where they are. A flat face has its C at infinity, and the diagram says so on that side. - Rays clipped by a mount stop there (dot). - Dashed grey backward extensions show where a virtual image is. - Optional full bundle of 15 rays from the tip. - White screen: shows what really lands on it, computed by tracing thousands of rays from every point of the arrow: - sharp at the real image; - blurred elsewhere; - coloured fringes with the white LED (chromatic aberration). - Probe plane: a see-through, non-physical plane that plots where the outgoing rays, or their backward extensions, cross. It is the only place a virtual image appears. - Real image in space: shown as a glowing arrow where light actually converges (and the intermediate image in two-lens setups). - 2D ray diagram with true lens profiles, mount apertures, F, F′, 2F, 2F′ and principal planes H, H′. An optional thin-lens textbook construction can be overlaid for comparison. - Readouts: - focal length at the chosen wavelength; - centre and edge thickness; - principal-plane offsets; - s and s′ from the principal planes, with a check of 1/s + 1/s′ = 1/f; - the thin-lens guess measured from the lens centre; - image position, height and magnification; - traced best focus and blur; - blue versus red image position. - Presets: - object beyond 2F, at 2F, between F and 2F, at F; - inside F (magnifier); - diverging lens; - 4f relay; - two-lens microscope; - converging + diverging pair. - Generated parts table and CSV.
1. Refraction at each surface (Snell's law). At every spherical glass surface a ray bends by n₁ sin θ₁ = n₂ sin θ₂, measured from the surface normal.
Handled: exact 3D vector tracing: - intersect the ray with the sphere (or plane); - compute the normal; - refract with t = η d + (η cos θᵢ − √(1 − η² sin² θᵢ)) N.
Rays outside the clear aperture of the retaining ring hit the mount and stop (45.7 mm for Ø2" in LMR2/M + SM2RR; 69 mm for the default Ø3" in LMR3/M + SM3RR, ASSUMED). Rays below the mount hit the post. Rays above the mount pass by.
1b. Surface shapes. Every surface is a biconic with curvatures c_y and c_z:
s(y, z) = (c_y y² + c_z z²) / (1 + √(1 − c_y² y² − c_z² z²))
This is exactly a sphere when c_y = c_z and exactly a cylinder when one curvature is zero; for the toric lens it is the standard biconic approximation. A turned lens is handled by rotating (y, z) into the lens frame.
Handled: the ray–surface intersection is found by Newton's method from the vertex plane; the normal comes from the gradient (1, −∂s/∂y, −∂s/∂z). In each plane the paraxial power uses c_plane = c_y cos²φ + c_z sin²φ (φ = lens rotation).
2. Glass index and dispersion. n(λ) for N-BK7 from the Sellmeier formula: n_d = 1.5168, about 1.524 at 470 nm and 1.515 at 625 nm.
Handled: each wavelength is traced separately. With the white LED, three colours (470, 550, 625 nm) are traced and added.
3. Thick-lens cardinal points (paraxial). Each surface has power P = (n₂ − n₁)/R. Glass of thickness t is a translation t/n. Multiplying the 2 × 2 ray matrices gives [[A, B], [C, D]], and from it: - f = −1/C; - F′ = x_b − A/C; - F = x_a + D/C; - H′ = x_b + (1 − A)/C; - H = x_a + (D − 1)/C.
The image of an object at distance s₀ before the first vertex is at s_i = −(A s₀ + B)/(C s₀ + D) after the last vertex, with magnification m = A + C s_i.
Handled: exact (paraxial). This is what the readouts and the "move to image" buttons use. For real images, the traced best focus (minimum RMS blur of the full-aperture tip bundle) is used instead.
4. The diagram rays from the arrow tip: - parallel to the axis; - aimed at the front principal (= nodal, in air) point H; - along the line through the front focal point F; - to 92 % of the clear radius.
Handled: launched from the paraxial cardinal points, then traced exactly. Because they are real rays, they miss the ideal image slightly (aberration) and can be clipped by the mount, exactly as on a bench.
5. Real versus virtual image. After the last lens, the rays from one object point either converge (real image: light is there, and a screen shows it) or diverge (virtual: only their backward extensions meet).
Handled: - Screen: stops the light; it records only the points where rays actually arrive. - Probe: takes each ray's final straight line and evaluates it at the probe position, forward or backward. It also ignores the screen, because it is not a physical object.
6. Image formation. For each of about 80 points on the arrow, about 400 rays fill the first lens aperture (stratified random samples, rotated per point), per wavelength. Each landing point is spread bilinearly onto a 300 × 300 grid (100 mm screen, 120 mm probe), lightly smoothed and auto-exposed.
Firefly light. Fireflies make light by bioluminescence: the enzyme luciferase oxidizes luciferin, and the excited product emits yellow-green light peaking near 560 nm. The process is very efficient, with little heat (it is often called "cold light"). The lantern is an extended, incoherent source like the candle flame: every point on it sends light in all directions, so the lens images it exactly like any other object (a small, inverted glowing patch at the image plane). Handled: the lantern is a grid of emitting points across a 3 × 4 mm patch, with a yellow-green colour (mostly the green band, some red, almost no blue); the body emits nothing, and when the lantern is dark the object has no points at all.
src/rt_model.js:Pure functions; runs in Node.
- src/rt_app.js:
- three.js bench (breadboard, rail, carriers, post holders, posts, LMR2/M mounts with retaining rings, lathe-profiled lenses, LED/diffuser/mask object, screen, probe plane);
- drag-on-rail;
- 3D rays and images, 2D diagram, readouts, parts table.
- src/rt_shell.html + src/build.py: page; python build.py inlines everything into ray_tracing_bench.html.
| Parameter | Value | Source |
|---|---|---|
| Lenses | Ø50.8 mm N-BK7, A coating; LA1145/1050/1384/1417/1353/1256 (f = 75–300 mm) | Thorlabs catalogue |
| Lens geometry | R = (n−1)f (plano-convex); edge 3 mm; LA1050: computed R 51.7 mm (catalogue 51.5), tc 9.7 mm | catalogue / computed |
| Glass | N-BK7 Sellmeier; n_d = 1.5168 | Schott |
| Clear aperture | Ø45.7 mm (Ø2", SM2RR in LMR2/M); Ø69 mm (Ø3" default, SM3RR in LMR3/M) | ASSUMED from drawings |
| Optical axis height | 220 mm above the table (room for Ø10" optics) | design choice |
| Rail | 1200 mm dovetail (RLA1200/M), RC2/M carriers, PH50/M + TR75/M | Thorlabs |
| Object | 4–20 mm arrow with flag on an LED-lit diffuser | design choice |
| Wavelengths | 470 / 550 / 625 nm (white LED), or 530 or 625 nm | typical LED peaks |
| Screen / probe | 100 × 100 mm card / 120 × 120 mm virtual plane | design choice |
Everything drawn in the 3D view, counted for the configuration shown. Thorlabs metric part numbers. Ø2" lens part numbers marked "verify" are the right type and size, but confirm the exact catalogue number for the focal length.