Premium apps Part of Proofline
Lens & Mirror Ray Tracer (ABCD + Real Rays)
Focal length, principal planes, image and spherical aberration of a lens or mirror system.
Try an example: Plano-convex N-BK7 lens, curved side towards the light · Same lens turned round: flat side towards the light · Biconvex thick lens imaging an object 150 mm away · Two thin lenses 50 mm apart · Concave spherical mirror R = −200 mm · Cemented achromat N-BAK4 / N-SF5 (thin-lens design for f = 100 mm)
How it works
Describe a sequential optical system line by line — thin lenses, thick lenses, spherical or flat refracting surfaces with glass indices, spherical mirrors and gaps — and get the effective focal length, back and front focal distances, principal planes, the image position and magnification for an object distance, and the paraxial marginal and chief ray heights at every surface from ABCD ray-transfer matrices. Real rays are traced exactly through the spherical surfaces with Snell’s law to show the longitudinal and transverse spherical aberration, with an SVG ray diagram, an aberration plot and a chromatic focal-shift estimate from the glass Abbe number. Part of the Proofline math notebook.
- Paraxial optics with 2 × 2 ray-transfer (ABCD) matrices acting on the height y and the reduced angle n·u: a gap d in index n is [[1, d/n], [0, 1]], a refracting surface [[1, 0], [−(n′ − n)/R, 1]], a thin lens [[1, 0], [−1/f, 1]] and a mirror a refraction with n′ = −n (power −2n/R). The system matrix gives the power φ = −C, the effective focal length 1/φ, the back focal distance A·n′/φ, the front focal distance D·n/φ and the principal planes.
- For a finite object the matrix is extended by the object distance; the image lies where the height of an axial ray returns to zero, and the lateral magnification is 1/D of the extended matrix.
- Exact rays start at the axial object point (or parallel to the axis), are intersected with each spherical surface and refracted with the vector form of Snell’s law (or reflected); their axis crossings relative to the paraxial focus give the longitudinal spherical aberration, their heights in the paraxial image plane the transverse aberration. Thin lenses are treated as ideal paraxial lenses.
- Chromatic estimate: nF − nC = (nd − 1)/νd from the glass Abbe number, split around nd; the paraxial calculation is repeated for the F and C lines.
- Verified against the lensmaker’s equation with thickness, the ball-lens formula f = nD/4(n − 1), the two-lens formula 1/f = 1/f₁ + 1/f₂ − d/(f₁f₂), the exact single-surface and spherical-mirror intercepts, and the textbook result that a plano-convex lens with its curved side towards collimated light has about four times less spherical aberration than the other way round.
A meridional, monochromatic 2-D model for checking and teaching: no skew rays, coma or astigmatism maps, vignetting by lens edges, tolerances or diffraction. Glass data are the d-line values of a few catalogue glasses; real designs need the full dispersion formula of the melt.
Sources
- E. Hecht: Optics, 5th ed. (Pearson, 2017), chapters 5 and 6 (thin and thick lenses, matrix methods, aberrations) (Pearson)
- W. J. Smith: Modern Optical Engineering, 4th ed. (McGraw-Hill, 2008), chapters 2, 3 and 10 (paraxial optics, real ray tracing, sign convention) (McGraw-Hill)
- SCHOTT optical glass data sheets (nd, νd for N-BK7, N-BAK4, N-SK16, F2, N-SF5, N-SF11) (SCHOTT AG)
- I. H. Malitson: Interspecimen comparison of the refractive index of fused silica, J. Opt. Soc. Am. 55 (1965) 1205–1209 (Optica)
Part of Proofline
-
Proofline Math notebook
Solve, graph, test and visualise in one notebook — with data, findings and a report.
Related tools
- Depth of Field, Field of View & Exposure Calculator – Near and far sharpness limits, hyperfocal distance, angle of view, crop factor and ND filters.
- Numerical Equation Solver & Optimizer – Every root of f(x) = 0 in an interval, Newton or bisection steps, systems and minima.
- Curve Fitter & Regression Calculator – Fit lines, polynomials, exponentials or your own model: parameters, R², errors, residuals.
- Matrix & Linear Algebra Lab – Exact-fraction RREF with steps, determinant, inverse, null space, eigenvalues, LU/QR and Ax = b.
Trace rays through lenses and mirrors with ABCD matrices and Snell's law
Describe a lens or mirror system line by line and get its focal length, principal planes, image position and spherical aberration with a ray diagram.
What it is for
When you combine lenses, turn a lens round or add a mirror, the textbook formulas get tedious. This tool takes an optical system written one element per line and computes the effective focal length, back and front focal distances, principal planes, and where the image of an object lands and how large it is.
The elements are lens f=… (ideal thin lens), gap … (distance to the next element), surface R=… n=… (a refracting surface into glass or air; R=inf is flat), thick R1=… R2=… t=… n=… (a thick lens) and mirror R=…. Lengths are in millimetres; a radius is positive when its centre of curvature lies to the right. Glass names such as N-BK7 or N-SF5 fill in the index and Abbe number.
Paraxial values come from 2 × 2 ray-transfer matrices; real rays are then traced exactly to show spherical aberration. It is a flat, single-wavelength model without skew rays or diffraction.
Worked example
A 100 mm plano-convex N-BK7 lens, 5 mm thick, with an aperture radius of 10 mm. Written curved side first, thick R1=51.68 R2=inf t=5 n=N-BK7, the tool reports an effective focal length of 100 mm and a back focal distance of 96.7036 mm: the rear principal plane sits 3.296 mm inside the lens, on the curved vertex. The f-number is 5.
The real-ray table shows how far each ray misses the paraxial focus. The marginal ray at 10 mm crosses the axis 1.09927 mm before it (undercorrected), and misses the axis by 0.111886 mm in the paraxial image plane.
Now turn the lens round: thick R1=inf R2=-51.68 t=5 n=N-BK7. The focal length is still 100 mm and the back focal distance becomes exactly 100 mm, but the marginal ray now falls 4.38184 mm short. Facing the curved side towards parallel light gives about four times less spherical aberration, the classic textbook rule. The Abbe-number estimate puts the blue–red focus difference at about 1.54–1.56 mm, close to f/V.
How to read the result
Effective focal length is 1/φ of the whole system. Back focal distance is measured from the last element along the light to the focus; front focal distance from the front focal point to the first element. The cardinal-points table locates H and H′ and gives the system matrix.
The surface table lists the paraxial marginal and chief ray heights, which tell you how large each lens must be. With a finite Object distance you also get the image distance (negative means a virtual image) and the lateral magnification.
The ray diagram marks F, F′, H and H′; its horizontal and vertical scales differ.
Tips and common mistakes
- Put a
gapbetween elements. Two lines without a gap sit at the same position. - After a mirror the light travels back, but radii keep their absolute sign: a second concave mirror facing the returning light has R > 0.
- Thin lenses are ideal and add no aberration. Use
thickorsurfacelines to see real spherical aberration. - If a ray reports total internal reflection or a missed surface, reduce the aperture radius.
- The aperture stop is at the first element, so chief-ray heights assume the stop there.
FAQ
Can it design an achromat?
It can check one. The cemented N-BAK4/N-SF5 example shows a colour focus shift of about 0.13 mm instead of the 1.5 mm of a single lens, but there is no optimiser.
Why is the effective focal length negative?
The system diverges light. Two lenses 150 mm and −75 mm, 40 mm apart, give −321.429 mm.
How exact is the spherical aberration?
The real rays follow Snell's law exactly through spheres, so the intercepts are exact for meridional rays at one wavelength.
Which glasses are included?
N-BK7, N-BAK4, N-SK16, F2, N-SF5, N-SF11 and fused silica at the d line. Any other material works as a number, with an optional Abbe number v=….
Guide last updated:
For scripts and AI agents
- JSON API:
POST https://prooflineraytracer.usefulweb.site/api/v1/calculate(same calculation as this page) - Interface description: OpenAPI 3.1 · AI guide: llms.txt
- MCP server (Streamable HTTP):
https://prooflineraytracer.usefulweb.site/mcp· tool nameproofline_ray_tracer
Example request
curl -s -X POST https://prooflineraytracer.usefulweb.site/api/v1/calculate \
-H 'content-type: application/json' \
-d '{"elements":"thick R1=51.68 R2=inf t=5 n=N-BK7","apertureRadius":10,"rays":5}'