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.
- 3 raysdrawn from your own a and f
- M = −b/amagnification, real or virtual image
- 4 median from 1.0003 to 2.417
- D = i₁ + i₂ − Adeviation through a prism
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 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.
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.
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.
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₂.
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.
| Applies to | Formula | Meaning |
|---|---|---|
| Lens and mirror | 1/f = 1/a + 1/b; M = −b/a | real image for b > 0, upright for M > 0 |
| Snell's law | n₁·sin θ₁ = n₂·sin θ₂ | angles from the normal to the boundary |
| Critical angle | sin θ_c = n₂ / n₁ | only for n₁ > n₂ |
| Prism deviation | D = i₁ + i₂ − A | A is the apex angle; r₁ + r₂ = A |
| Minimum deviation | n = 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.
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.
Related tools
Electric field simulation and magnetic field calculatorElectric field simulation with field lines of charges, plus the magnetic field of a wire, loop and solenoid and the Lorentz force in numbers. Free online.
Vibrations and WavesPendulum period calculator with the exact period up to 170°, plus damped springs, resonance, interference, standing waves and the Doppler effect. Free online.
Wall U-value calculatorWall U-value calculator with dew point, Glaser condensation, thermal bridge, part cooling, fins and radiation. Free, 3 times a day without an account.
Physics Constants & Formula SolverPhysics constants and formulas in one place: 17 constants from SI 2019 and CODATA 2022, plus 17 formulas to solve for any unknown, with unit conversion.
Draw your own rays
Opens without an account 3 times a day. A free account removes the limit.