# Lens & Mirror Ray Tracer (ABCD + Real Rays) > Focal length, principal planes, image and spherical aberration of a lens or mirror system. 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. Part of usefulweb.site (https://usefulweb.site/). Part of [Proofline](https://proofline.usefulweb.site/) (ownerApp: proofline). Results are deterministic calculations from the inputs and the listed assumptions; the API returns exactly what the web page shows. ## Use it - Human interface: https://prooflineraytracer.usefulweb.site/ (interactive tool at https://prooflineraytracer.usefulweb.site/tool) - JSON API: POST https://prooflineraytracer.usefulweb.site/api/v1/calculate with a JSON object of inputs (schema: https://prooflineraytracer.usefulweb.site/api/v1/tool) - OpenAPI: https://prooflineraytracer.usefulweb.site/openapi.json - MCP (Streamable HTTP): https://prooflineraytracer.usefulweb.site/mcp - tool `proofline_ray_tracer` ## Inputs - elements (textarea, required): Optical system (one element per line) - Elements in the order the light meets them, lengths in mm: “lens f=100” (thin lens), “gap 20” (distance to the next element), “surface R=50 n=1.5168” (refracting surface into index n; R=inf for flat), “thick R1=50 R2=-50 t=6 n=N-BK7” (thick lens in the current medium), “mirror R=-200” (concave mirror facing the light). R > 0 when the centre of curvature is to the right. Glasses: N-BK7, N-BAK4, N-SK16, F2, N-SF5, N-SF11, fused silica, or a number with an optional Abbe number v=…; # starts a comment. - objectDistance (text): Object distance - Distance in mm from the object to the first element, or inf for an object at infinity (parallel light). Negative values mean a virtual object behind the first element. - objectHeight (number): Object height - Finite objects: height of the object point the chief ray starts from. - fieldAngle (number): Field angle - Objects at infinity: angle of the chief ray to the axis. - apertureRadius (number): Aperture radius - Semi-diameter of the beam at the first element (the aperture stop). The real rays fill it evenly. - rays (integer): Real rays - Number of exact rays between the axis and the aperture edge. ## Method - 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. ## Limits - 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.