Rays and optical pathlength minimization My textbook, Fundamentals of Photonics, Third Edition, by Saleh and Teich, says the following in a section on Planar Boundaries:

The relation between the angles of refraction and incidence, $\theta_2$ and $\theta_1$, at a planar boundary between two media of refractive indices $n_1$ and $n_2$ is governed by Snell's law (1.1-3). This relation is plotted in Fig. 1.2-8 for two cases:
$\blacksquare$ External Refraction ($n_1 < n_2$). When the ray is incident from the medium of smaller refractive index, $\theta_2 < \theta_1$ and the refracted ray bends away from the boundary.
$\blacksquare$ Internal Refraction ($n_1 > n_2$). If the incident ray is in a medium of higher refractive index, $\theta_2 > \theta_1$ and the refracted ray bends toward the boundary.

The refracted rays bend in such a way as to minimize the optical pathlength, i.e., to increase the pathlength in the lower-index medium at the expense of pathlength in the higher-index medium. In both cases, when the angles are small (i.e., the rays are paraxial), the relation between $\theta_2$ and $\theta_1$ is approximately linear, $n_1 \theta_1 \approx n_2 \theta_2$, or $\theta_2 \approx (n_1/n_2)\theta_1$.

Reading what the authors have said here, and comparing it to figure 1.2-8, when they say that the optical pathlength is minimized, they're referring to the pathlength from the origin of the ray to some imaginary vertical line on the $n_2$ medium side, right? is this a correct way to conceptualize the minimization of optical pathlength?
 A: You know that ray propagation in a homogeneous medium is straight line. Now assume that you are given both the source point in medium 1, say P, and a point Q in medium 2 that lies on the true refracted ray and let $X_0$ be the point on the interface of the two media where the ray refracts. For any point $X$ on the interface form the sum $L[X]=n_1 PX + n_2 XQ$ where $PX$ and $XQ$ are the lengths of the straight line segments in hte respective medium. Fermat' principle states that as $X$ is infinitesimally varied around $X_0$ the optical path length $L[X] \ge L[X_0]$
Note too that one can replace the fixed point $Q$ in medium 2 with a given fixed direction and minimize a different optical path length. Fix an arbitrary reference $Z$ and for every straight line in medium 2 project $Z$ unto the line, say $T$ and now measure the optical path length (distance time refractive index) from the fixed $P$ to $T$: $L_1[X] = n_1 PX + n_2 XT$ where now the segment $XT$ is now the fixed direction. Then again the minimum of  $L_1[X]$ as $X$ is varied within an infinitesimal neighborhood of the actual $X_0$ at the interface takes its minimum value with Snell's law! This modification of Fermat's principle is due to Hamilton.
