In optics, a ray of light traveling between two points takes the path that requires the least amount of time, even if it's not the shortest distance  which is known as "Fermat's principle of least time.