Physics · Introductory

Thin lens ray diagram

Written by SignalsLab

Early edition: these lessons are being reviewed.

Content

Summary

A thin lens bends light rays so that they meet (converging lens) or appear to spread from (diverging lens) a point, forming an image. Three special rays, one parallel to the axis, one through the lens centre, and one through the focal point, let us locate the image and predict its size and orientation.

Intuition

Think of a lens as a stack of tiny prisms. A converging lens is thicker in the middle, so rays far from the centre are bent more, and parallel rays are brought together at the focal point. Every point on an object sends out many rays, and the lens redirects them all to one image point. We do not need to trace every ray: three easy ones cross at the same place, and that crossing marks the image of the top of the object. The bottom of the object sits on the axis, so its image also sits on the axis directly below or above the top image point.

Key equations

1f=1do+1di
(1)

Thin lens equation relating focal length f, object distance d_o and image distance d_i (real-is-positive convention).

m=hiho=−dido
(2)

Magnification: image height over object height; a negative value means the image is inverted.

P=1f
(3)

Lens power in dioptres when f is in metres.

Derivation

  1. Draw the principal axis, a vertical thin lens, and mark the focal points F at distance f on both sides.
  2. Place an upright object arrow of height h_o at distance d_o to the left of the lens.
  3. Ray 1: from the arrow tip, travel parallel to the axis, then bend at the lens to pass through the far focal point.
  4. Ray 2: from the tip, go straight through the lens centre without deviation.
  5. Ray 3: from the tip, aim through the near focal point; after the lens it emerges parallel to the axis.
  6. The three rays intersect at one point: the image of the tip, at distance d_i beyond the lens.
  7. Using similar triangles formed by ray 2, the object and image heights give h_i/h_o = d_i/d_o.
  8. Using similar triangles formed by ray 1 at the lens and the focal point gives h_o/f = h_i/(d_i - f), which combined with the previous result yields 1/f = 1/d_o + 1/d_i.

Worked example

Problem

A converging lens has focal length 10 cm. An object 2 cm tall is placed 30 cm from the lens. Find the image position, height and orientation.

  1. Write the lens equation: 1/10 = 1/30 + 1/d_i.
  2. Solve: 1/d_i = 1/10 - 1/30 = 3/30 - 1/30 = 2/30 = 1/15, so d_i = 15 cm.
  3. Magnification m = -d_i/d_o = -15/30 = -0.5.
  4. Image height h_i = m × h_o = -0.5 × 2 cm = -1 cm.

Answer The image is real, 15 cm beyond the lens, inverted, and 1 cm tall (half size).

Common mistakes

  • Bending rays at the lens surfaces instead of drawing a single bend at the central plane for a thin lens.
  • Using the wrong focal point: the parallel ray goes through the far focal point, not the near one.
  • Forgetting that the central ray is undeviated.
  • Mixing sign conventions, such as forgetting that a negative magnification means inverted.
  • Placing the object inside the focal length and expecting a real image; in that case the image is virtual, upright and magnified, found by extending rays backward.

Animation

Animation coming soon

The animated version of this lesson is being prepared for the web. In the Signals AI app, lessons are drawn step by step.

Code

scene.py(79 lines)
import sys
import numpy as np
from manim import *
from blocks import *

F = 1.5      # focal length (scene units)
DO = 3.0     # object distance
HO = 1.0     # object height


def image_position(do, f):
    """Thin lens equation 1/do + 1/di = 1/f, return di and magnification."""
    di = 1.0 / (1.0 / f - 1.0 / do)
    return di, -di / do


DI, M = image_position(DO, F)
HI = M * HO


class Main(Scene):
    def construct(self):
        self.camera.background_color = "#10141c"
        TitleCard(self, "Thin lens ray diagram")

        # Optical axis and lens at the origin, shifted up a little
        c = 0.3 * UP
        axis = Line(c + 6.5 * LEFT, c + 6.5 * RIGHT, color=C_DIM)
        lens = Line(c + 2.2 * DOWN, c + 2.2 * UP, color=C_MAIN, stroke_width=6)
        lens_tip = VGroup(
            Triangle(color=C_MAIN, fill_opacity=1).scale(0.12).move_to(c + 2.2 * UP + 0.1 * UP),
            Triangle(color=C_MAIN, fill_opacity=1).scale(0.12).rotate(PI).move_to(c + 2.2 * DOWN + 0.1 * DOWN),
        )
        f1 = Dot(c + F * RIGHT, color=C_ACCENT, radius=0.07)
        f2 = Dot(c + F * LEFT, color=C_ACCENT, radius=0.07)
        fl1 = Text("F", font_size=24, color=C_ACCENT).next_to(f1, DOWN, buff=0.15)
        fl2 = Text("F", font_size=24, color=C_ACCENT).next_to(f2, DOWN, buff=0.15)
        self.play(Create(axis), Create(lens), FadeIn(lens_tip))
        self.play(FadeIn(VGroup(f1, f2, fl1, fl2)))

        # Object arrow
        base = c + DO * LEFT
        obj = Arrow(base, base + HO * UP, buff=0, color=C_GOOD)
        top = base + HO * UP
        self.play(Create(obj))
        StepCaption(self, "Ray 1: parallel to axis, then through focus")

        # Ray 1: parallel, then through far focus
        lens_pt1 = c + HO * UP
        itop = c + np.array([DI, HI, 0])
        r1a = Line(top, lens_pt1, color=C_BAD)
        r1b = Line(lens_pt1, itop, color=C_BAD)
        self.play(Create(r1a))
        self.play(Create(r1b))
        StepCaption(self, "Ray 2: through the lens centre, undeviated")

        # Ray 2: straight through centre
        r2 = Line(top, itop, color=C_ACCENT)
        self.play(Create(r2))

        # Image
        ibase = c + DI * RIGHT
        img = Arrow(ibase, itop, buff=0, color=C_GOOD)
        self.play(Create(img))
        eq = MathTex(r"\frac{1}{d_o}+\frac{1}{d_i}=\frac{1}{f}", font_size=30)
        eq.to_corner(UR, buff=0.4).shift(0.6 * DOWN)
        self.play(Write(eq))
        StepCaption(self, "Real inverted image where the rays meet")
        self.wait(1.5)


if __name__ == "__main__" and "--selftest" in sys.argv:
    di, m = image_position(DO, F)
    assert abs(di - 3.0) < 1e-9          # do = 2f gives di = 2f
    assert abs(m + 1.0) < 1e-9           # inverted, same size
    assert abs(1 / DO + 1 / di - 1 / F) < 1e-9
    # ray through centre passes through image top (similar triangles)
    assert abs(HI / DI - (-HO / DO)) < 1e-9
    print("ok")

The Manim scene code that draws this lesson's animation in the Signals AI app (Python, Manim Community).

ccBYNC© 2026 SignalsLab. Lesson text shared as is under CC BY-NC 4.0.