Thin Lens Ray Tracer Back
Optics · Lens Design

Thin Lens Ray Tracer & Optics Simulator

Drag sliders to watch three principal rays update in real time. Instantly see image distance, magnification, and whether the image is real or virtual for convex and concave lenses.

Optical Settings
Mode
Focal Length f₁ (mm) 100
Object Distance dₒ (mm) 200
Object Height hₒ (mm) 40
Presets

Thin Lens Equation

$$\frac{1}{f}= \frac{1}{d_o}+ \frac{1}{d_i}$$

Magnification: $m = -\dfrac{d_i}{d_o}$

$d_i > 0$: real image   $d_i < 0$: virtual image

$|m| > 1$: magnified   $|m| < 1$: reduced

CAE Application: Geometrical optics (ray tracing) is used in illumination system design, camera module engineering, and numerical aperture (NA) calculations for optical fibers. For wave-scale effects, FDTD or FEM electromagnetic analysis is used.
— mm
Image Distance dᵢ
—×
Magnification m
— mm
Image Height hᵢ
Image Type
Parallel → through F'
Through F → parallel
Through center
Virtual image (dashed)

What is Thin Lens Ray Tracing?

🧑‍🎓
What exactly is the "thin lens equation" I see in the simulator? It looks like a simple formula, but how does it predict where an image will form?
🎓
Basically, it's the master rule for a single, simple lens. The equation $1/f = 1/d_o + 1/d_i$ relates three distances: the focal length $f$, the object distance $d_o$, and the image distance $d_i$. In practice, if you know any two, you can solve for the third. Try it in the simulator: set a positive focal length (like 100 mm) and drag the "Object Distance" slider. Watch how the traced rays converge to form the image at the exact $d_i$ the equation predicts.
🧑‍🎓
Wait, really? So if I move the object really close to the lens, the image goes far away? And what does a negative $d_i$ mean in the "Image Info" panel?
🎓
Exactly! That's the beauty of the equation. A negative $d_i$ means the image is virtual—the rays *appear* to diverge from a point on the same side of the lens as the object. You can't project it on a screen. A common case is a magnifying glass. Try it: use a convex lens ($f > 0$) but put the object *inside* the focal point ($d_o < f$). The rays won't converge on the other side; the image distance will turn negative, indicating a virtual, upright, and magnified image.
🧑‍🎓
Okay, that makes sense for one lens. But the simulator has a "Two-Lens System" mode. How does that work? The rays look way more complicated!
🎓
Great question! For two lenses, we apply the thin lens equation *sequentially*. The image from the first lens becomes the *object* for the second lens. The key is the "Lens Separation" $d$ parameter. Change it and watch the rays bend. For instance, in a simple telescope, you have two lenses separated by the sum of their focal lengths. The simulator calculates this step-by-step, tracing the rays in real time so you can see how the final image position and magnification emerge from the interaction.

Physical Model & Key Equations

The fundamental law governing a single ideal thin lens is the Gaussian Lens Formula. It assumes the lens thickness is negligible and uses the paraxial approximation (small angles).

$$\frac{1}{f}= \frac{1}{d_o}+ \frac{1}{d_i}$$

$f$: Focal length of the lens. $f > 0$ for converging (convex) lenses, $f < 0$ for diverging (concave) lenses.
$d_o$: Object distance (positive if object is on the side from which light is coming).
$d_i$: Image distance. $d_i > 0$ indicates a real image (formed on the opposite side of the lens). $d_i < 0$ indicates a virtual image (formed on the same side as the object).

The lateral magnification $m$ tells you the size and orientation of the image relative to the object. It is derived from similar triangles in the ray diagram.

$$m = -\frac{d_i}{d_o}= \frac{h_i}{h_o}$$

$m$: Magnification. $|m| > 1$ means the image is larger than the object. The sign of $m$ indicates orientation: $m > 0$ means the image is upright, $m < 0$ means the image is inverted.
$h_o$, $h_i$: Object height and image height, respectively.

Real-World Applications

Camera Lens Design: Engineers use these exact ray-tracing principles to design lens elements. By combining multiple lenses with different focal lengths and separations, they correct for aberrations and focus light precisely onto a camera sensor. The "Two-Lens System" mode in this simulator is a foundational model for such compound lenses.

Microscopes & Telescopes: These instruments are essentially precise arrangements of two or more lenses. A microscope uses a short-focal-length objective lens to create a magnified real image, which is then viewed through an eyepiece (acting as a magnifying glass). The overall magnification is the product of the magnifications of each stage.

Vision Correction (Eyeglasses): A prescription lens is designed to take an object at a desired distance (e.g., a book at 25 cm for a presbyopic eye) and form a virtual image at the eye's own far point, allowing the eye to focus it properly. This simulator helps visualize how concave or convex lenses shift the apparent image location.

Illumination & Optical Sensor Systems: In automotive lighting, projectors, or barcode scanners, engineers use geometrical optics to direct light from a source (like an LED) through lenses to create a specific beam pattern or to focus light onto a detector. This is a core CAE application for ensuring efficiency and performance before physical prototyping.

Common Misconceptions and Points to Note

First, understand that the "thin lens" concept does not negate real-world lenses. Actual lenses have thickness and aberrations. This simulator is an "ideal first-order approximation model." For example, smartphone camera lenses use multiple cemented elements to cancel aberrations, but their initial design is based on this thin lens model. Next, strict adherence to sign conventions is critically important. If you input a positive focal length for a concave lens or consider the distance to a virtual image as positive, all calculations will be off. Even when using professional optical design software, this convention is often the default setting. Third, avoid setting the lens separation too extremely in "Two-Lens Mode." For instance, bringing a 10cm and a 5cm focal length lens as close as 1cm causes rays to bend sharply, making the image appear behind the lens. This is an unrealistic combination; in actual microscopes, there is a specific fixed distance called the "tube length" between the objective and eyepiece lenses.

Related Engineering Fields

The core technique of this simulator, "ray tracing," is a fundamental method underlying various CAE fields. The most direct application is illumination optical design. For systems like car headlamps or projector optics, designers trace tens of thousands of rays from the light source (LED or lamp) as they travel through lenses and mirrors to achieve the required light distribution pattern. Next is the optical design for semiconductor lithography systems (steppers). Extremely complex multi-lens groups image a mask's fine pattern onto a silicon wafer with minimal distortion, and geometric optics models are used in the foundational design stages. Broadening the view, the same concept applies to radio wave and acoustic propagation analysis. For example, designing a reflector to focus radio waves from an antenna or simulating acoustics in a concert hall uses "ray tracing methods," where "electromagnetic waves" or "sound rays" are traced instead of "light." Thus, for modeling phenomena where structures are large compared to the wavelength, ray tracing is the starting point.

For Further Learning

Once you're comfortable with this simulator, the next step is to explore the world of "thick lenses" and "aberrations." While a thin lens has a single focal length, a real lens has front/back surface radii of curvature and thickness. This introduces the concept of "principal points," from which object and image distances must be measured. The fastest way to understand this is to manually calculate the actual refraction of rays (sequential application of Snell's Law) using trigonometry. For example, calculate where a parallel ray entering a plano-convex lens at a slight height above the optical axis intersects it. This lets you experience the deviation from the ideal focal point (spherical aberration). To learn further, consider the effects of "diffraction" as a bridge to wave optics. Diffraction, which occurs precisely because a lens has a finite aperture, ultimately determines image sharpness (resolution). Understanding why what images as a "point" in this thin lens simulator actually becomes a blurred disc called an "Airy disk" in reality will double the fun of optical design.