This chapter aims to extend Fermat's principle of least time to include the phase advance of the incident radiation that occurs at a grating. A detailed analysis of toriodal gratings follows, including the special case of spherical gratings. In the case of a diffraction grating, the phase advance of the radiation which occurs at the grating must be included in the optical path function. The optimization of the efficiency of gratings has been worked out in the electromagnetic theory regime, the results of which can be incorporated in the ray trace calculations. In ordering laminar gratings the groove width to groove period ratio must be optimized for the wavelengths to be dispersed. Two mirrors in grazing incidence are rotated parallel to each other causing a parallel shift in the optical path. The reflectivity as a function of energy and angle of incidence as calculated from the optical constants for three double mirror systems.