HomeArticlesOptics & Light

Laser Labyrinth: Reflection, Refraction and the Physics of a Light Puzzle

How the law of reflection and Snell's law turn a handful of mirrors and glass blocks into a solvable optics puzzle.

mysimulator teamUpdated June 2026≈ 7 min read▶ Open the simulation

Two laws, one ray

Every beam in the labyrinth obeys exactly two rules. At a mirror, the law of reflection says the angle of incidence equals the angle of reflection, both measured from the surface normal: θ_i = θ_r. At a glass boundary, the beam bends according to Snell’s law, which relates the incident and transmitted angles to the refractive indices of the two media on either side of the surface.

law of reflection:   theta_i = theta_r
Snell's law:         n1 * sin(theta_i) = n2 * sin(theta_2)

n1, n2 = refractive index of medium 1 and 2 (vacuum/air ~= 1.0, glass ~= 1.5)
theta measured from the surface normal, not the surface itself
live demo · a wavefront bending across a boundary● LIVE

Both laws fall out of one idea: Fermat’s principle, that light travels between two points along the path that takes stationary (usually least) time. In a uniform medium the fastest path is a straight line, so a ray is a straight segment until it hits an interface. At a mirror, reflection is the only path that keeps the light in the same medium and satisfies the stationary-time condition, which forces equal angles. At a refracting boundary, light trades speed for direction — it travels slower in the denser medium (speed v = c/n) — and the geometry that minimises total travel time is exactly Snell's law.

Building the ray tracer

The simulation is a 2-D ray tracer: each frame, cast a ray from the source, find the nearest surface it intersects, and either reflect or refract it, then repeat until the ray exits the scene, hits the target, or a bounce limit is reached. Reflection is a vector formula, no trigonometry needed at run time:

// d = incoming direction (unit vector), n = surface normal (unit vector)
r = d - 2 * dot(d, n) * n;   // reflected direction, one dot product

Refraction uses the vector form of Snell's law, folding the sines and cosines into dot products so the renderer never calls asin in the hot loop. The ratio eta = n1/n2 decides whether the ray bends toward or away from the normal. There is one extra case a working optics sandbox must handle: total internal reflection. When light tries to leave a denser medium at a shallow enough angle, no real transmitted ray exists — the term under Snell's square root goes negative — and the ray reflects instead of refracting. That threshold, the critical angle, is what makes glass rods and optical fibres trap light by bouncing it down the inside wall indefinitely.

Dispersion: why prisms split white light

Refractive index is not a single number for a material — it depends weakly on wavelength, a property called dispersion. Blue light bends slightly more than red light passing through the same glass because n(blue) > n(red). A prism exploits this: white light entering one face refracts by a different amount per colour, so the colours separate and exit the second face at a fan of angles. The same physics explains the rainbow, where refraction inside spherical raindrops (plus one internal reflection) spreads sunlight into its spectrum at a fixed 42° angle from the antisolar point.

Puzzle design: why targets are solvable

A laser-labyrinth puzzle is really an inverse problem: given fixed mirrors and glass blocks, find rotations that route the beam onto the target. Because reflection and refraction are both deterministic, the whole path is a pure function of the mirror angles — turn a mirror by 5° and every downstream segment of the beam rotates predictably around the pivot. That determinism is what makes the puzzle fair: there is always a reachable configuration, and small adjustments produce small, traceable changes in where the beam lands, rather than chaotic jumps.

Frequently asked questions

Why does the beam sometimes reflect off glass instead of entering it?

That is Fresnel reflection plus, at steep enough angles measured from the normal, total internal reflection. Real glass always reflects a few percent of the light at any interface; beyond the critical angle for light leaving the denser medium, 100% of it reflects and none is transmitted.

Does the colour of the beam matter here?

In this simulator the beam is treated as a single wavelength, so it bends by one fixed amount at each glass surface. In reality every wavelength has a slightly different refractive index (dispersion), which is why a real prism fans white light into a spectrum instead of refracting it as one ray.

What decides whether a mirror reflects or a block refracts?

The material assigned to the surface. Mirrors are modelled as fully reflective, so only the law of reflection applies. Glass blocks are modelled with a refractive index around 1.5, so light entering or leaving them bends according to Snell's law, and can also reflect partially or totally depending on the angle.

Try it live

Everything above runs in your browser — open Laser Labyrinth and change the parameters while it is running. Nothing is installed, nothing is uploaded, the whole model lives in one tab.

▶ Open Laser Labyrinth simulation

What did you find?

Add reproduction steps (optional)