Skip to content
ScienceQuest
Waves & Optics Simulator School

Refraction Simulator

Refraction is light bending as it changes speed: n₁ sin θ₁ = n₂ sin θ₂. Trace a ray through a boundary, a glass block and a prism, and split white light.

Simulator

Drag the light source around the point where the ray strikes, or use the arrow keys to change the angle of incidence by 1° and Page Up and Page Down by 10°.

Angle of refraction
Measured from the normal, like the angle of incidence.
25.08 °
Critical angle
sin θc = n₂/n₁. It exists only when the light heads into a lower index.
None
Reflected
Unpolarised light, the mean of the s and p reflectances from the Fresnel equations.
4.80 %
Transmitted
Everything that is not reflected, since neither medium absorbs.
95.20 %
Brewster angle
tan θB = n₂/n₁. At this angle none of the p-polarised light is reflected.
56.60 °
Speed in second medium
c/n. The slowing is what bends the ray.
197,648 km/s

Light in air meets crown glass at 40.0° from the normal and refracts to 25.1°, bending towards the normal. 4.80% is reflected.

Parameters
°

Measured from the normal, not from the surface. Drag the light source to change it.

Traces 400 to 700 nm through the materials that have a measured dispersion fit.

  • Unpolarised
  • s-polarised
  • p-polarised
Share of the light reflected at the boundary against the angle of incidence, for s and p polarisation and for unpolarised light. The p curve falls to zero at Brewster’s angle; heading into a lower index, every curve jumps to 100 per cent at the critical angle.

Citing this tool

Last updated . Add the date you accessed it as well, which a citation of a page that can change asks for. If a specific result matters, cite the permalink from the tool’s share row instead of this page: it reproduces the exact parameters.

Teaching with this? You can put it on a class page or LMS for free, with no ads inside the frame. Get the embed code.

The equation

n1sin⁡θ1=n2sin⁡θ2,sin⁡θc=n2n1n_1\sin\theta_1 = n_2\sin\theta_2, \quad \sin\theta_c = \frac{n_2}{n_1}

Snell (1621) and Descartes (1637), with Fresnel (1823) for reflection

What refraction is

Refraction is the change in direction of light as it crosses into a medium where it travels at a different speed. Snell’s law gives the new direction, n₁ sin θ₁ = n₂ sin θ₂, with both angles measured from the normal, the line perpendicular to the surface. The refractive index n = c/v says how many times slower light travels in a medium than in vacuum, so light that slows down bends towards the normal and light that speeds up bends away from it.

This simulator follows one ray through three arrangements: a single boundary between two media, a parallel-sided block, and a triangular prism. Pick either medium from 30 materials in the refractive index table, every one but silicon and germanium, which are opaque to visible light, or type your own index, then drag the light source or use the angle slider. The readouts give the angles, the share of the light the first surface reflects, the critical angle, and for the prism the deviation and its minimum; the plot draws the reflected share, the block’s shift or the prism’s deviation against the angle of incidence. The Snell’s law calculator solves the same equation for any one of its four terms.

Worked example: air into crown glass at 40°

The simulator opens with light in air, n₁ = 1.000293, striking crown glass, n₂ = 1.5168, at 40° from the normal.

  • sin θ₂ = n₁ sin θ₁ / n₂ = 1.000293 × 0.6428 / 1.5168 = 0.4239
  • θ₂ = arcsin 0.4239 = 25.08°, so the ray bends 14.92° towards the normal.
  • The Fresnel equations send 4.80% of the light into the reflected ray and 95.20% into the refracted one.

Switch the scene to the block and the same ray crosses 5 cm of the glass and comes out at 40° again, shifted sideways by 5 × sin 14.92° / cos 25.08° = 1.421 cm. Send it back out of the glass at 25.08° and it leaves at 40°: a ray traced backwards retraces its path.

The critical angle and total internal reflection

Light heading into a lower index bends away from the normal, and at one angle of incidence the refracted ray would have to run along the surface. That is the critical angle, sin θc = n₂/n₁, and past it no ray refracts at all: all of the light is reflected, which is total internal reflection. Start the light in crown glass and send it into air, and the critical angle reads 41.26°; at 45° the reflected share reads 100%. From water into air it is 48.63°, and from diamond only 24.45°. Going the other way, into a higher index, there is no critical angle at any incidence.

The reflection does not switch on at the critical angle. It climbs steeply towards it: at 41.0° from crown glass into air, 56.84% of the light is already reflected and the refracted ray leaves at 84.17°, almost along the surface. The plot of reflected share against angle shows the curve rising to 100% and staying there.

The refractive index table lists 41.2° for crown glass because its column treats air as exactly 1; with air’s measured 1.000293 the angle is 41.26°. The two ways of counting air differ by under 0.02° for every material here.

Through a block, the ray comes out parallel

A parallel-sided block refracts the ray twice. Its second face is parallel to the first, so it undoes the first face’s bending exactly and the ray leaves in its original direction, shifted sideways by d = t sin(θ₁ − θ₂) / cos θ₂. The shift is zero at normal incidence and grows towards the thickness of the block as the light approaches grazing, which is the curve the plot draws in this scene. It is the glass block experiment: trace the ray in and out on paper, join the two points, and the angle inside gives the index.

The faint rays beside the main ones are light reflected inside the block: some comes back out through the top, parallel to the first reflection, and some leaves the bottom parallel to the main ray. A block never splits white light into a spectrum, for the same reason it keeps the direction: every colour leaves parallel to the others, only shifted by slightly different amounts, 0.25 mm apart for 5 cm of crown glass at 40°.

Through a prism: deviation and minimum deviation

In a prism the two faces meet at the apex angle A, so their bending adds instead of cancelling and the ray is turned towards the base. With r₁ the refraction angle at the first face, the ray meets the second face at r₂ = A − r₁, leaves at an angle e that Snell’s law gives there, and has been turned through the deviation δ = i + e − A.

Sweep the angle of incidence and the deviation falls to a minimum and rises again. The minimum comes when the ray crosses symmetrically, r₁ = r₂ = A/2, and then n = sin((A + δmin)/2) / sin(A/2), with n the prism’s index relative to its surroundings. For the 60° crown glass prism in air, sin i = (1.5168 / 1.000293) × sin 30° = 0.7582, so the incidence is 49.30° and δmin = 2 × 49.304° − 60° = 38.61°. At the opening 40° the deviation reads 40.23°, a little above the minimum. Measuring the minimum deviation on a spectrometer is how the index of a glass is found.

Below 29.15° the second face of that prism reflects everything back inside, and a 90° crown glass prism, whose apex is more than twice the 41.26° critical angle, lets no light through the second face at any angle. Textbook problems often take n = √3 with A = 60°, which gives a minimum deviation of exactly 60°: type 1.732 as a custom index with vacuum outside and the simulator reads 59.99°, the rounding of √3 showing in the last digit.

Why a prism makes a spectrum

Turn on white light and the simulator traces 31 wavelengths from 400 to 700 nm, each with its own index. Glass bends violet more than red because its index is higher at shorter wavelengths, which is dispersion. Through the 60° crown glass prism at 49.3°, its minimum deviation, the 400 nm and 700 nm rays leave 1.58° apart. Change the prism to dense flint glass, whose index varies more than three times as much across the band, and at 59.7°, beside its own minimum deviation, they leave 7.50° apart.

The indices come from published dispersion fits rather than from interpolation. 7 materials here have one: the three Schott catalogue glasses, fused quartz (Malitson, 1965), water (Daimon and Masumura, 2007), diamond (Peter, 1923) and calcium fluoride (Malitson, 1963). Each fit is checked against published figures that do not come from the fit itself, among them the Schott data sheets’ Abbe numbers: 64.17 for crown glass, 36.37 for flint and 28.41 for dense flint, where a lower number means more dispersion. A material without a fit keeps its 589 nm index for every colour, and the simulator says so; air’s own index changes by under 0.00001 across the band, too little to move a ray on the screen.

How much light is reflected

Every boundary between different indices reflects part of the light, and the Fresnel equations say how much. At normal incidence it is ((n₂ − n₁)/(n₂ + n₁))², 4.21% from air into crown glass. The share grows with the angle, slowly at first and then steeply towards grazing incidence, where almost everything reflects: 99.00% at 89.9°. The two polarisations differ. The s component, whose electric field lies along the surface, reflects more at every oblique angle; the p component falls to zero at Brewster’s angle, tan θB = n₂/n₁, which is 56.60° from air into crown glass. That is why light reflected from glass or water near that angle is polarised. The rays and the readouts use unpolarised light, the average of the two.

Where the law comes from

The law is named after Willebrord Snellius, who found it in 1621 but never published it; René Descartes printed it in 1637, and the historian Roshdi Rashed (1990) identified the same law in Ibn Sahl’s treatise on burning mirrors and lenses, written in Baghdad in 984. Augustin-Jean Fresnel derived how much light a surface reflects in a memoir of 1823.

What this simulator leaves out

  • Curved surfaces. Every face here is flat. A lens bends each ray by a different amount across its surface, which is the job of the ray diagram simulator and the thin lens calculator.
  • Waves. Light is traced as rays, which holds while every surface is far larger than the wavelength. Slits a few wavelengths wide diffract and interfere instead, which is what the double slit simulator shows.
  • Two rays in one crystal. Calcite, crystalline quartz, sapphire, moissanite and magnesium fluoride split light into two rays with different indices. The simulator uses the ordinary index for each, so it draws one.
  • Absorption and temperature. No medium absorbs, and every index is the table’s value at the temperature the table quotes it for. The block and the single boundary extend without edges, and branches carrying under a thousandth of the light are not drawn.

Common mistakes

  • Measuring from the surface. Both angles in Snell’s law are measured from the normal. A ray at 20° to the surface has an angle of incidence of 70°.
  • Taking the ratio of the angles. It is the ratio of the sines that stays fixed. Doubling the angle of incidence from 20° to 40° takes the refraction angle in crown glass from 13.04° to 25.08°, not to twice 13.04°.
  • Expecting total internal reflection going into glass. It only happens heading into a lower index. From air into glass there is a refracted ray at every angle.
  • Forgetting the surroundings. What bends light is the ratio of the two indices. The same 60° crown glass prism in water turns light through only 9.35° at minimum deviation, against 38.61° in air.
  • Adding the prism angles wrongly. The two angles inside add up to the apex, r₁ + r₂ = A, and the deviation is i + e − A, not i + e.
  • Thinking the colour changes inside glass. The frequency is set by the source and does not change; the wavelength shortens by the factor n, and the colour you see when the light leaves is the colour that went in.

Model and assumptions

Method
Exact expression, no time stepping
Repeatability
Deterministic. The same link gives the same numbers on any machine.

What it assumes

  • Geometric optics at flat surfaces: Snell’s law gives every refraction angle and the Fresnel equations the share of unpolarised light each surface reflects, both evaluated exactly.
  • The media are uniform, isotropic and transparent, so nothing is absorbed, and a birefringent crystal takes its ordinary index.
  • Light of one colour takes each medium’s refractive index table value at 589 nm. White light takes the published dispersion fit of each material that has one, from 400 to 700 nm, and vacuum and air keep a single index.
  • The drawn ray is followed surface by surface until a branch carries under a thousandth of the light, and it agrees with the closed forms the readouts use.

Where it stops holding. Curved surfaces, where the normal turns from point to point, so a lens needs its own treatment rather than a sequence of flat faces. The Ray Diagram Simulator is the right tool there.

Numerical accuracy

No method error to report: the result is a closed-form expression evaluated directly, with no time stepping to accumulate error. What remains is double-precision rounding, of order one part in 10^16 per operation.

Refraction Simulator: the equation n₁ sin θ₁ = n₂ sin θ₂, sin θ c = n₂/n₁.
The equation the simulator is built on, with its source. Image © ScienceQuest, CC BY 4.0. Free to reuse with credit and a link to this page; how to reuse it. Download PNG

Common questions

What is refraction?

The change in direction of light as it crosses into a medium where it travels at a different speed. The refractive index n = c/v measures the slowing, and Snell’s law, n₁ sin θ₁ = n₂ sin θ₂, gives the new angle from the normal. Light entering crown glass from air at 40° goes on at 25.08°, bent towards the normal because it slows from 299,705 km/s in air to 197,648 km/s in the glass.

When does total internal reflection happen?

When light inside a denser medium meets the boundary at more than the critical angle, where sin θc = n₂/n₁. Past that angle no ray refracts and all of the light is reflected. The critical angle is 41.26° from crown glass into air, 48.63° from water into air and only 24.45° from diamond into air. Heading into a denser medium there is no critical angle at all.

Why does a prism split white light into colours?

Because glass has a higher index for violet light than for red, so violet bends more at each face, which is dispersion. Through a 60° crown glass prism at minimum deviation the 400 nm and 700 nm rays leave 1.58° apart, and dense flint glass, whose index varies more than three times as much across that band, spreads them 7.50° apart near its own minimum deviation. The indices come from the Schott glass catalogue’s measured dispersion data, not from interpolation.

What is the angle of minimum deviation?

The smallest angle a prism can turn a ray through, reached when the ray crosses the prism symmetrically and leaves at the angle it entered. For a 60° crown glass prism in air it is 38.61°, at an angle of incidence of 49.30°. The prism’s index relative to its surroundings is then sin((A + δmin)/2) / sin(A/2), which is how a prism spectrometer measures the index of a glass.

Why does light leave a glass block parallel to how it went in?

Because the block’s faces are parallel, so the second face undoes the bending at the first exactly. The ray is only shifted sideways, by t sin(θ₁ − θ₂)/cos θ₂: a 5 cm crown glass block moves a ray arriving at 40° by 1.42 cm. For the same reason a block cannot split white light into a spectrum, since every colour leaves parallel to the others.