Skip to content

Ray diagram generator and calculator for lenses, mirrors and prisms

Enter the object distance and the focal length and get a ray diagram, the image distance and the magnification. The same tool calculates refraction with the critical angle and the deviation through a prism, all online in your browser.

Opens without an account 3 times a day. A free account removes the limit.

Ray optics simulation: what the tool draws and calculates

This ray optics simulation from EduFacturing draws a ray diagram for a thin lens and a spherical mirror, calculates refraction by Snell's law and finds the deviation of a ray through a prism.

Ray optics simulation: the Lens tab with a converging lens, sliders for the object distance (20) and the focal length (10), a ray diagram with three rays and the results b = 20 cm and M = −1
Ray optics simulation: the Lens tab with a converging lens, sliders for the object distance (20) and the focal length (10), a ray diagram with three rays and the results b = 20 cm and M = −1

Ray diagram, mirror, refraction, prism: what you get

Draws three rays through a lens or a mirror

One parallel to the axis, one through the centre (to the vertex for a mirror) and one through the focus. They are redrawn on every change of a and f. Dashed lines are backward extensions for a virtual image or focus.

Determines the image: real or virtual

Gives b in cm, the magnification M, whether the image is real or virtual, upright or inverted, enlarged, reduced or the same size. An object exactly at the focus gives a message that there is no image.

Calculates refraction and the critical angle

Pick two of four media and an angle of incidence from 0° to 89°. You get the angle of refraction and the critical angle, or a message about total internal reflection.

Calculates the deviation through a prism

Set an apex angle from 10° to 170° and a material (water, glass or diamond) and get r₁, r₂, i₂ and the deviation D, at minimum deviation or at a set angle of incidence.

Lenses, mirrors and total internal reflection: when it helps

Mistakes with lenses and mirrors are rarely arithmetic. They come from a drawing that does not match the number.

  • A lesson on lenses

    With f = 10 cm, an object at 20 cm gives b = 20 cm and M = −1, at 15 cm gives M = −2, and at 5 cm gives a virtual upright image with M = 2. Each classic case is one slider position.

  • Total internal reflection

    From glass to air the critical angle is 41.15°, from diamond 24.45°, from water 48.63°. Above it there is no refracted ray.

  • A prism lab

    At A = 60° and n = 1.52 the minimum deviation is 38.93°. A measured D_min can be checked against the formula n = sin((A + D_min)/2) / sin(A/2) shown in the tab.

How the image in a lens and refraction are calculated

Lens and mirror use one formula, refraction and prism use Snell's law.

  1. Signs and formula

    a > 0 for a real object; f > 0 for a converging lens and a concave mirror, f < 0 for a diverging lens and a convex mirror; b > 0 for a real image, b < 0 for a virtual one. Then b = a·f / (a − f) and M = −b/a.

  2. Diagram

    The rays are built from a and f. A lens has two focal points, F and F′, and a mirror one, because it sends the light back to the object's side. A test guards this.

  3. Refraction

    Angles are measured from the normal. If the sine of the refraction angle would exceed 1, there is no refracted ray: total internal reflection. A critical angle exists only for n₁ > n₂.

  4. Prism

    The ray refracts at the first face (r₁), r₂ = A − r₁, leaves at i₂, and D = i₁ + i₂ − A. At minimum deviation the path is symmetric.

The formulas the tool uses
Applies toFormulaMeaning
Lens and mirror1/f = 1/a + 1/b; M = −b/areal image for b > 0, upright for M > 0
Snell's lawn₁·sin θ₁ = n₂·sin θ₂angles from the normal to the boundary
Critical anglesin θ_c = n₂ / n₁only for n₁ > n₂
Prism deviationD = i₁ + i₂ − AA is the apex angle; r₁ + r₂ = A
Minimum deviationn = sin((A + D_min)/2) / sin(A/2)i₁ = i₂ = (A + D_min)/2; if n·sin(A/2) > 1 there is no symmetric path

The drawing and the number agree

  • The drawing and the number agree

    A test checks that the three rays cross exactly at the image. The prism is drawn with vector refraction and checked against the scalar formula.

  • It says what it leaves out

    The indices are for one wavelength, and a note at the bottom of the tool says so.

What it does not do

The tool does not model dispersion: the indices are for the sodium yellow line, 589 nm, so the prism does not split white light into colours. There are four media, and an index cannot be typed in.

The formula is for a thin lens and a spherical mirror, one element at a time, not a system of elements. The prism is triangular and symmetric.

Questions about the lens, mirror, critical angle and prism

How to draw a ray diagram for a lens?

Draw three rays: one parallel to the axis, one through the centre and one through the focus. The image is where they cross, or for a virtual image where their backward extensions cross. Here you enter a and f and the tool draws all three.

What is the thin lens equation?

1/f = 1/a + 1/b, and the magnification is M = −b/a. With f = 10 cm, an object at 20 cm gives b = 20 cm and M = −1. A mirror uses the same formula with the same signs.

How do I tell a real image from a virtual one?

For b > 0 the image is real and the rays themselves cross. For b < 0 it is virtual: only their backward extensions cross, drawn dashed, and the image cannot be caught on a screen.

What is total internal reflection, and what is the critical angle from glass to air?

Above the critical angle there is no refracted ray and the light reflects back. From glass to air (n = 1.52 and 1.0003) the critical angle is 41.15°.

What is the minimum deviation of a prism?

The deviation when the ray passes symmetrically, i₁ = i₂. For A = 60° and glass with n = 1.52 it is 38.93°. A diamond prism with A = 60° has no symmetric path, because n·sin(A/2) = 1.21 is above 1.

Is the ray optics simulation free?

Yes. Without an account it opens 3 times a day. A free account removes the limit.

The ray optics simulation is free. Pro opens the rest

Pro costs 15 EUR a month and opens 45 Pro tools.

Draw your own rays

Opens without an account 3 times a day. A free account removes the limit.