API & MCP

Everything a person can do on Lens & Mirror Ray Tracer (ABCD + Real Rays), a program or AI agent can do with the same inputs and get the identical result.

HTTP API

Lens & Mirror Ray Tracer (ABCD + Real Rays)

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.

Inputs of Lens & Mirror Ray Tracer (ABCD + Real Rays)
FieldTypeDefaultDescription
elements (required)textarea—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.
objectDistancetext"inf"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.
objectHeightnumber10Object height. Finite objects: height of the object point the chief ray starts from.
fieldAnglenumber5Field angle. Objects at infinity: angle of the chief ray to the axis.
apertureRadiusnumber10Aperture radius. Semi-diameter of the beam at the first element (the aperture stop). The real rays fill it evenly.
raysinteger5Real rays. Number of exact rays between the axis and the aperture edge.

Example request

Plano-convex N-BK7 lens, curved side towards the light

curl -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}'

Every result contains

inputs (normalised, defaults applied), summary, result (validated against the published schema), units, assumptions, sources, warnings, computedAt and links.

MCP (Model Context Protocol)

{
  "mcpServers": {
    "proofline-ray-tracer": { "type": "http", "url": "https://prooflineraytracer.usefulweb.site/mcp" }
  }
}