Periodic structures, called diffraction gratings, play an important role in optical lithography. The diffraction of the incident field in multiple diffraction orders provides a way to accurately determine a position on a wafer on one hand and on the other hand it provides a test method to determine the quality of the photolithographic process. For both applications it is crucial to be able to find the actual shape of the structure to correct for damages or imperfections. When besides the incident field also the shape of a diffraction grating is known, we can compute the diffracted field by using the rigorous coupled-wave analysis (RCWA) or the C method. These methods solve Maxwell’s equations for time-harmonic fields directly, which is requ...