Dynamic Programming, Fermat’s Principle, and the Eikonal Equation