Refraction

A mirror sends a ray straight back; glass and water do something subtler — they let it through, but bent. A straw in a glass looks snapped at the waterline, a coin in a pond sits shallower than it really is, and a diamond throws sparks of colour. All of it is one law about how a ray turns as it crosses from one transparent material into another. After reflection, refraction is the second ray a raytracer casts at a surface.

Every material carries an index of refraction n — roughly, how much it slows light down. Vacuum is n = 1, water about 1.33, glass about 1.5, diamond 2.42. The bend depends only on the two indices and the angle.

Snell's law, line by line

Measure every angle from the normal (the line perpendicular to the surface), not from the surface itself. Call the incoming angle in medium 1 \theta_1 and the outgoing angle in medium 2 \theta_2.

Step 1 — the law. A ray crossing from index n_1 into index n_2 obeys

n_1 \sin\theta_1 = n_2 \sin\theta_2.

The quantity n\sin\theta is conserved across the boundary. That single conserved product is the whole content of refraction.

Step 2 — solve for the new angle. Divide through by n_2:

\sin\theta_2 = \frac{n_1}{n_2}\sin\theta_1.

Step 3 — read off the bend direction. Going into a denser medium (n_2 > n_1), the ratio n_1/n_2 < 1 shrinks the sine, so \theta_2 < \theta_1 — the ray bends toward the normal. Air into water tilts the ray more upright; that's why the submerged straw appears to kink toward vertical. Going the other way, into a thinner medium, it bends away from the normal.

Step 4 — building the refracted direction vector

A raytracer needs a direction, not just an angle. Split the unit incoming direction \vec{D} the same way reflection did — into a part along the normal and a part in the surface (the tangential part):

\vec{D}_{\perp} = \vec{D} - (\vec{D}\cdot\vec{N})\,\vec{N}, \qquad \lVert\vec{D}_{\perp}\rVert = \sin\theta_1.

Snell's law scales the tangential part by n_1/n_2 (that's exactly \sin\theta_2 = (n_1/n_2)\sin\theta_1 in vector clothing), and the normal part is fixed by the unit length of the new direction. Writing \eta = n_1/n_2, the refracted direction is

\vec{T} = \eta\,\vec{D}_{\perp} \;-\; \sqrt{\,1 - \eta^2\,\lVert\vec{D}_{\perp}\rVert^2\,}\;\vec{N},

which is a unit vector pointing into medium 2, bent by exactly the Snell angle.

Step 5 — when the square root breaks: total internal reflection

Go from a denser medium to a thinner one (n_1 > n_2, so \eta > 1) and push \theta_1 up. Step 2 demands

\sin\theta_2 = \frac{n_1}{n_2}\sin\theta_1,

but a sine can never exceed 1. The right-hand side hits 1 at the critical angle

\theta_c = \arcsin\!\left(\frac{n_2}{n_1}\right),

and past it there is no real \theta_2 — equivalently, the quantity under the square root in Step 4 goes negative. Physically, nothing escapes: the boundary becomes a perfect mirror and the ray reflects entirely back inside. This is total internal reflection, the trick that pipes light down a glass fibre for miles and makes the underside of a water surface flash silver.

A ray crossing from index n_1 into index n_2, with angles measured from the normal, satisfies:

Drop a straw into a glass of water and it appears to snap and jump sideways at the surface. Nothing is moving — your eye is just tracing light backwards. Rays leaving the submerged part of the straw bend away from the normal as they exit the water into air, so they reach your eye coming from a shallower, shifted direction than the straw truly sits.

Your visual system, which assumes light travels in straight lines, projects the straw back along those bent rays and places it where they seem to originate — higher and offset. Same physics raises a coin in a pond toward you and makes a pool look shallower than it is. One conserved product, n\sin\theta, and the world quietly lies about where things are.