🪞 Mirrors & Lenses
Geometric optics ray diagram. Choose a lens or mirror type, adjust focal length and object distance, and watch three principal rays form a real or virtual image. Uses the thin-lens equation 1/f = 1/do + 1/di.
Geometric optics ray diagram. Choose a lens or mirror type, adjust focal length and object distance, and watch three principal rays form a real or virtual image. Uses the thin-lens equation 1/f = 1/do + 1/di.
This ray tracer demonstrates geometric optics: how a single lens or mirror forms an image of an upright object. It draws the three principal rays and solves the thin-lens (and mirror) equation 1/f = 1/do + 1/di, then computes the magnification m = -di/do. By switching between converging and diverging elements you can watch real and virtual images appear, flip orientation, and grow or shrink as the object crosses the focal point.
For a chosen optical element the simulator applies a sign convention (converging f > 0, diverging f < 0), solves 1/di = 1/f - 1/do for the image distance, and derives magnification m = -di/do and image height. A positive image distance gives a real, projectable image; a negative one gives a virtual image seen by looking into the element.
Pick the element from the dropdown (converging or diverging lens, concave or convex mirror). Use the three sliders to set focal length f (40-250 px), object distance do (30-450 px) and object height (20-120 px). The panel reports image distance, magnification and height live, and a badge labels the image real or virtual, upright or inverted.
A converging lens only makes a magnified upright (virtual) image when the object sits inside the focal length - that is exactly how a magnifying glass works. Move the object past the focal point and the image flips, becoming real and inverted.
A real image forms where light rays actually converge, so it can be projected onto a screen and the simulator marks it with a solid green arrow. A virtual image forms where rays only appear to come from, behind the lens or mirror; it cannot be projected and is drawn as a dashed yellow arrow. In the maths a positive image distance di means real, while a negative value means virtual.
It uses the thin-lens and mirror equation 1/f = 1/do + 1/di, rearranged to 1/di = 1/f - 1/do. Converging elements take a positive focal length and diverging ones a negative focal length. The magnification is then m = -di/do, and image height is m times the object height.
They are the standard principal rays used to construct an image. The red ray travels parallel to the optical axis and then passes through the focal point F'. The green ray goes straight through the centre of the lens (or to the centre of a mirror) undeviated. The blue ray passes through the near focal point F and emerges parallel to the axis. Dashed segments are virtual extensions used to locate virtual images.
A diverging lens has a negative focal length, so 1/di = 1/f - 1/do is always negative for a real object. That makes the image distance negative, meaning the image is always virtual, upright and reduced in size. A convex mirror behaves the same way, which is why it is used for wide-angle car and shop mirrors.
It uses the ideal thin-lens approximation, which assumes the lens is infinitely thin and rays stay close to the axis (the paraxial regime). That makes it a faithful teaching model, but it ignores real-world effects such as spherical and chromatic aberration, lens thickness and finite aperture. Distances are shown in pixels rather than physical units, so it illustrates the relationships rather than predicting a specific camera or telescope.