Modeling and analysis of transients in periodic gratings. II. Resonant wave scattering.