A Byte of PhysicsLogo

Reflection and refraction

Ray optics is a geometric model of light. It works when the scale of lenses, interfaces, and paths is much larger than the wavelength and when diffraction can be ignored. A ray diagram is only trustworthy when it labels its interface, normal, refractive indices, and angle convention.

Think like a programmer

Represent a ray by direction, origin, medium index, and wavelength context. Measure all incidence, reflection, and refraction angles from the normal—not from the surface. Put total internal reflection in the result type instead of forcing an invalid floating-point angle.

Model checklist

Inputs
Incident angle from the normal, incident and transmitted refractive indices, and an interface normal.
State
Ray origin, direction, current medium, and the interface being intersected.
Rule
Reflect by mirroring about the normal; transmit according to Snell's law when a real angle exists.
Output
Reflected angle, refracted angle, or total-internal-reflection status.
Check
Equal refractive indices preserve direction; reflection angle equals incidence angle.

The reflection rule is

\[\theta_{\mathrm{reflection}}=\theta_{\mathrm{incidence}}\]

For transmission between ideal media, Snell's law is

\[n_1\sin\theta_1=n_2\sin\theta_2\]

If the computed value for sin(θ2) has magnitude greater than one, there is no real transmitted angle in this model. Report total internal reflection instead of calling asin and accepting NaN.

Snell's-law ray experiment

Change the incoming angle and the two refractive indices. The normal is vertical; all reported angles are measured from it.

Incident and refracted ray
Reflected ray
Interface and normal

Reflected angle: 35.0°. Refracted angle: 22.5°.

The ray diagram is unavailable. The labelled angles and total-internal-reflection status above describe the same model.
const sine = (n1 / n2) * Math.sin(incidentAngle);
const transmittedAngle = Math.abs(sine) > 1 ? null : Math.asin(sine);

The null result is an informative physical branch. It tells the UI to draw a reflected ray and explain why no refracted ray is displayed.

Try this experiment

Prediction: When light enters a higher-index medium, its ray bends closer to the normal.

Set the incident index to 1.00 and transmitted index to 1.50. Increase the incident angle, predict the refracted angle, and compare it with the labelled result. Then reverse the indices and find a total-internal-reflection case.

Where this model breaks

This model assumes smooth planar interfaces, homogeneous isotropic media, and a single wavelength. It omits polarization, absorption, scattering, dispersion, surface roughness, wave interference, diffraction, and finite beam width.

Summary

Ray optics turns an interface into a clear branch: reflect every incident ray, refract when Snell's law has a real solution, and report total internal reflection otherwise. Keep the normal and every angle convention visible.

Glossary

Self-check

  1. From which line should ray angles be measured?
  2. What result should equal indices produce?
  3. Why is null a better result than NaN for total internal reflection?

Sources

Model contract

Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.

\[\text{observable output} = f(\text{inputs},\,\text{state})\]
Inputs
Quantities you set or measure, with units and useful bounds.
State
Values the program must retain to reproduce the next result.
Rule
The relationship or update that turns inputs and state into a result.
Check
A known limit, unit check, invariant, or measured result that can expose a bad model.

Implement the idea as a model

For Reflection and Refraction, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Geometric and Wave Optics, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.

Guided experiment

Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.

Where this model breaks

This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.

Summary

Treat Reflection and Refraction as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.

Glossary

  • Input: a measured value or chosen parameter supplied to a model.
  • State: the smallest set of values needed to continue or reproduce a model.
  • Validation: comparing an output with a known result, limit, invariant, or measurement.

Self-check

  1. Which values are inputs, and which values must remain state?
  2. What observable result would tell you the model is behaving as expected?
  3. Which assumption would you test first before applying the model to a real system?

Model review: turn Reflection and Refraction into a test

Implement optical interface geometry as pure ray updates with normal-incidence tests.

  1. Name the inputs and units that the geometric and wave optics model needs.
  2. Separate the state you must keep from values you can calculate when needed.
  3. Write one rule that maps the current state and inputs to an observable result.
  4. Choose a limiting case, unit check, invariant, or known result before trusting an output.
  5. State one assumption you would change before using this simplified model for a real decision.

Share to: