250px-Snells law

Fermat's principle leads to Snell's law; when the sines of the angles in the different media are in the same proportion as the propagation velocities, the time to get from P to Q is minimized.

In optics, Fermat's principle or the principle of least time is the principle that the path taken between two points by a ray of light is the path that can be traversed in the least time. This principle is sometimes taken as the definition of a ray of light.[1] However, this version of the principle is not general; a more modern statement of the principle is that rays of light traverse the path of stationary, not minimal, time.

Fermat's principle can be used to describe the properties of light rays reflected off mirrors, refracted through different media, or undergoing total internal reflection. It can be deduced from Huygens' principle, and can be used to derive Snell's law of refraction and the law of reflection.