Uni-Sine
Physics
+25XP
PhysicsWaves and light

Optics simulator: trace rays through lenses and mirrors

An optics simulator traces light rays through lenses, mirrors and glass so you can see where they bend, where they meet and what image they make, without an optics bench. Our optics simulator, the Ray Optics Simulator, works as a lens simulator and much more: put convex and concave lenses, plane and curved mirrors, prisms and glass blocks on the bench, aim an object, a point source or a beam at them, and it draws every ray using the law of reflection and Snell's law. It gives the image distance and magnification from the lens equation, and the angles of incidence and refraction at glass.

Try it

Ray Optics Simulator

Trace light rays through lenses, mirrors and prisms

Go to its page

How to use the optics simulator

  1. Open the Ray Optics Simulator. It opens on a convex lens with an object in front of it.
  2. Under Scenes, load a set-up: convex lens, magnifying glass, concave lens, concave mirror, parallel beam to a focus, prism spectrum, glass block, total internal reflection or periscope.
  3. Under Parts, add a convex or concave lens, a plane, concave or convex mirror, a prism or a glass block, and set each one's focal length (up to ±60 cm), size, refractive index, apex angle or the angle it is turned to.
  4. Under Light, choose an Object (an arrow), a Point source or a Beam, and set the number of rays. Turn on White light to split it into colours, and Normals and angles to see the normal at each surface.
  5. Read the image readings for a lens or mirror (u, v, f, magnification and what kind of image it is), or the angles for glass (incidence, refraction, critical angle, deviation and how many times the ray was totally reflected).

The lens and mirror equation

\frac{1}{u} + \frac{1}{v} = \frac{1}{f} \qquad m = -\frac{v}{u}u is the object distance, v the image distance, f the focal length, m the magnification

The simulator uses the real-is-positive convention, the same as most US textbooks write as 1/do + 1/di = 1/f. A converging (convex) lens or concave mirror has a positive f, a diverging one a negative f. A positive v is a real image that can be caught on a screen; a negative v is virtual. A negative magnification means the image is upside down.

Worked examples you can check in the simulator

Example 1: a convex lens forming a real image

The opening scene has an object 26 cm from a convex lens with f = 12 cm.

\frac{1}{v} = \frac{1}{12} - \frac{1}{26} \Rightarrow v = 22.29\ \text{cm} \qquad m = -\frac{22.29}{26} = -0.857

The readout says Real, inverted, diminished: the rays really cross 22.29 cm behind the lens, and the image is 0.857 times the height of the object, upside down. This is how a camera or your eye forms an image.

Example 2: moving the object

Drag the object closer. The table shows what a 12 cm convex lens does as it comes in:

Object distance uImage distance vMagnificationImage
36 cm18 cm−0.5Real, inverted, diminished
24 cm (2f)24 cm−1Real, inverted, same size
18 cm36 cm−2Real, inverted, magnified
12 cm (f)InfinityNoneRays leave parallel
8 cm (inside f, f = 14)−18.67 cm2.33Virtual, upright, magnified

The last row is the Magnifying glass scene: with the object inside the focal length, the rays spread out after the lens, and you see an upright, magnified, virtual image where they appear to come from.

Example 3: a concave lens

Load Concave lens: f = −12 cm, object at 26 cm. Then 1/v = −1/12 − 1/26, so v = −8.21 cm and m = 0.316. A diverging lens always gives a virtual, upright, diminished image, on the same side as the object.

Example 4: a concave mirror

Load Concave mirror: f = 12 cm, object 28 cm in front. v = 28 × 12 ÷ (28 − 12) = 21 cm and m = −0.75: a real, inverted, diminished image in front of the mirror, where the reflected rays cross.

Example 5: refraction in a glass block

Load Glass block (n = 1.5) and turn on normals. The ray meets the block at 28° to the normal. By Snell's law, n₁ sin θ₁ = n₂ sin θ₂, so sin θ₂ = sin 28° ÷ 1.5 and θ₂ = 18.24°: it bends towards the normal going in. It leaves at 28° again, parallel to where it started but shifted sideways. The Snell's law guide covers the formula.

Example 6: total internal reflection

Load Total internal reflection. Inside a 90° glass prism, the ray hits the long face at 45°. The critical angle for n = 1.5 is sin⁻¹(1 ÷ 1.5) = 41.8°, and 45° is bigger, so no light gets out: it is totally reflected, and the readout counts 1 total reflection. Prisms like this turn light round in binoculars and periscopes.

Try a refraction question, then press Mark to check your answer in the Light and Energy course.

Calculate the angle of refraction for a random pair of materials and angle.

Press Mark to have your answer marked in the Light & Energy course.

practice
Pick an answer, then check it.
An object is 30 cm from a convex lens with a focal length of 10 cm. Where is the image?

What the simulator doesn't do

  • Thick lenses and aberrations. Lenses and curved mirrors are ideal thin ones that bring rays exactly to a focus.
  • Lens systems in one reading. You can place several parts and the rays pass through them all, but the image readings are for the first lens or mirror the light meets. For two lenses, use the first image as the object for the second, by hand.
  • Wave optics. No diffraction, interference or polarisation (polarization in the US). Light here travels as rays.
  • Focal length from curvature. You set f directly; it doesn't use the lensmaker's equation.

Common mistakes

  • Sign of f. Diverging lenses and convex mirrors have a negative focal length.
  • Reading a negative v as an error. It means the image is virtual.
  • Measuring angles from the surface. Angles of incidence and refraction are measured from the normal.
  • Thinking total internal reflection needs a mirror. It happens at a glass-air boundary when light inside the glass hits it beyond the critical angle.

Common questions

What is an optics simulator?
A program that traces light rays through lenses, mirrors and glass, using the law of reflection and Snell's law, so you can see the image or the bending without an optics bench.
Can I use it as a lens simulator?
Yes. Put a convex or concave lens on the bench, move the object, and it gives the image distance, magnification and whether the image is real or virtual.
What is the lens equation?
1/u + 1/v = 1/f, with u the object distance, v the image distance and f the focal length. The magnification is −v/u.
When is the image from a convex lens virtual?
When the object is closer to the lens than the focal length. That is how a magnifying glass works.
What is the critical angle of glass?
For glass with a refractive index of 1.5 it is sin⁻¹(1/1.5) = 41.8°. Beyond it, light inside the glass is totally internally reflected.

Revision cards

Read the front, say your answer, then flip to check.

Where to go next

  • Solve it

    Ray Optics Simulator

    Trace light rays through lenses, mirrors and prisms

    Open the tool
  • Learn it

    Light & Energy

    Waves, photons and the electromagnetic spectrum explained

    Start the course
  • Test it

    High School Physics

    A new exam-style paper every day, with instant marking and a mark scheme

    Start today's paper
Read next
Physics · Waves and lightRefraction ray diagrams: how to draw and explain themHow to draw a refraction ray diagram, which way light bends at a boundary, the glass block practical, and why refraction happens, using wave fronts.