Snell's Law — Refraction & TIR

Explore how light bends when crossing between media with different refractive indices, and discover total internal reflection.

About this simulation

This interactive diagram shows how a light ray bends as it crosses the boundary between two transparent media. It solves Snell's law, n₁ sinθ₁ = n₂ sinθ₂, in real time to draw the incident, reflected and refracted rays. When light travels into a less dense medium at a steep enough angle the refracted ray vanishes and you witness total internal reflection — the principle that keeps light trapped inside optical fibres and makes diamonds sparkle.

🔬 What it shows

A ray meeting a horizontal interface between Medium 1 (index n₁) and Medium 2 (index n₂). The script computes the refraction angle from sinθ₂ = (n₁/n₂) sinθ₁; if that value reaches 1 it flags total internal reflection and renders an evanescent wave fading along the boundary instead of a refracted ray.

🎮 How to use

Drag the θ₁ slider (0–89°) to set the angle of incidence, or click in the upper half of the canvas to aim the ray. Use the n₁ and n₂ sliders (1.00–2.50) to change each medium, or pick a preset such as Air → Glass, Air → Diamond or Fibre Optic. The panel reports θ₂, the critical angle and the n₁/n₂ ratio.

💡 Did you know?

Diamond's very high refractive index of about 2.42 gives it a critical angle of only around 24.4°, so almost any light entering a cut diamond bounces around internally many times before escaping — which is why it appears so brilliant and fiery.

Frequently asked questions

What is Snell's law?

Snell's law relates the angles of incidence and refraction when light passes between two media: n₁ sinθ₁ = n₂ sinθ₂, where n₁ and n₂ are the refractive indices. It tells you exactly how much a ray bends, and it bends towards the normal when entering a denser medium and away from it when entering a less dense one.

How does the simulation calculate the refracted ray?

It converts your angle of incidence to radians, then computes sinθ₂ = (n₁/n₂) sinθ₁. If that result is below 1 it takes the arcsine to get the refraction angle θ₂ and draws the blue refracted ray. If it is 1 or greater no real angle exists, so the sim instead shows total internal reflection.

What do the controls do?

The θ₁ slider sets the angle of incidence from 0 to 89 degrees, and you can also click the top half of the canvas to set it. The n₁ and n₂ sliders change the refractive index of each medium between 1.00 and 2.50. Preset buttons load common pairings such as air to water, air to glass or a fibre-optic configuration that triggers reflection.

What is the critical angle and when does total internal reflection happen?

Total internal reflection occurs only when light moves from a denser medium into a less dense one, so n₁ is greater than n₂. The critical angle is given by sinθc = n₂/n₁. Once the angle of incidence exceeds this critical value the light cannot refract out and is reflected entirely back into the first medium.

Is this simulation physically accurate?

The geometry of the rays follows Snell's law and the critical-angle formula precisely, so the angles are correct. For clarity it simplifies the physics: it does not compute Fresnel reflection coefficients, so it does not show how the brightness splits between the reflected and refracted beams, and the evanescent wave is drawn as an illustration rather than a quantitative field.