How A Diffraction Grating Works