Ray tracing is one of the central tools of geometric optics. Instead of solving only one formula for one image location,
ray tracing follows light step by step as it interacts with multiple optical elements. That makes it especially useful for
systems containing several mirrors, several lenses, or a combination of both. In its simplest form, each ray is represented by
a starting point and a direction. The simulator then finds the next surface that the ray reaches, applies the appropriate optical law,
updates the direction, and repeats the process.
For a plane mirror, the key rule is the law of reflection: the angle of incidence equals the angle of reflection.
In vector form, if \(\mathbf{d}\) is the incoming unit direction and \(\mathbf{n}\) is a unit normal to the mirror surface,
the reflected direction is
\[
\mathbf{r}=\mathbf{d}-2(\mathbf{d}\cdot\mathbf{n})\mathbf{n}.
\]
This equation is extremely useful in simulation because it works directly with directions and surface normals.
Once the simulator has found the intersection point of a ray with the mirror segment, it can compute the outgoing direction immediately.
For a thin lens, a full exact ray treatment would require a more detailed refracting-surface model, but for an optical-bench style simulator
the standard paraxial thin-lens approximation is often enough. In that approximation, if a ray hits the lens at height \(y\) and its incoming slope is
\(u = dy/dx\), then the outgoing slope is updated by
\[
u' = u - \frac{y}{f},
\]
where \(f\) is the signed focal length of the lens. A converging lens has \(f>0\), and a diverging lens has \(f<0\).
This relation is one of the standard paraxial ray-tracing rules behind matrix optics.
In a simulator with multiple elements, the main computational task is not the formula itself but the sequence of intersections.
After launching a ray, the program checks all elements in the scene and determines which valid intersection lies nearest in the forward direction.
That element becomes the next optical interaction. After the direction changes, the search begins again from the new position.
In this way, successive reflections and refractions happen automatically.
This is why ray tracing is ideal for systems such as a periscope, an optical bench with several lenses, a folded beam path,
or a corner-reflector arrangement. A simple periscope-style path can be created with two mirrors that each turn the beam by 90°.
The first reflection redirects the light upward, and the second reflection redirects it forward again. A ray-tracing simulator makes that path immediately visible,
including the exact hit points on the mirror surfaces.
The benefit of tracing multiple rays instead of just one is that you can see the full ray bundle. When the rays remain tightly organized,
the system is imaging or transporting the beam cleanly. When they spread out or strike apertures differently, you can visually detect clipping,
field dependence, or poor alignment. This is why ray-bundle animation is so valuable in teaching optics.
At a more advanced level, the same ideas lead to matrix optics, where free-space propagation and thin-lens refraction are encoded by transfer matrices.
Mirrors and curved refracting surfaces can also be incorporated into more sophisticated systems. Even then, the conceptual picture stays the same:
the optical system is not just one equation, but a sequence of transformations applied to the rays.
This calculator uses a practical educational compromise. Plane mirrors are treated with the exact vector reflection law, while thin lenses are handled with the
paraxial slope update. That combination is simple enough to keep the code fast and readable, but rich enough to simulate multi-element scenes and repeated interactions.
As a result, the simulator works well for introductory optical-bench problems while also hinting at university-level ray-transfer methods.
In short, ray tracing turns geometric optics from a single-surface calculation into a step-by-step dynamical process.
That is exactly why it is the natural language of periscopes, folded optical systems, relay optics, and optical-bench design.