Thin Lens & Mirror API
Thin-lens and mirror imaging optics as an API, computed locally and deterministically. The lens endpoint applies the thin-lens equation, 1/f = 1/do + 1/di, and solves for whichever of the focal length, object distance or image distance you leave out, then returns the magnification m = −di/do and the full description of the image — real or virtual, upright or inverted, enlarged, reduced or the same size — and whether the lens is converging (convex, f > 0) or diverging (concave, f < 0). The mirror endpoint does the same for a spherical mirror, taking the focal length or the radius of curvature (f = R/2), classifying it as concave or convex and describing the image. The power endpoint converts between focal length in metres and optical power in diopters, D = 1/f, and combines several thin lenses placed in contact by adding their powers, D_total = ΣD, returning the combined focal length. Distances use whatever consistent unit you supply. Everything is computed locally and deterministically, so it is instant and private. Ideal for physics and optics-education tools, lens and optical-system design, eyewear and vision apps, and photography learning. Pure local computation — no key, no third-party service, instant. Live, nothing stored. 3 endpoints. This is geometric-optics imaging; for Snell's-law refraction angles use a Snell API and for camera depth of field and field of view use a photography API.
api.oanor.com/lens-api