We study the rigorous design and analysis of stacked rotated gratings (SRGs) for novel photonic devices. A concept of sampling frequency is proposed to systematically design SRGs. With the help of a rectangular sampling lattice, we extend the standard 3D rigorous coupled-wave analysis (RCWA) algorithm to the analysis of SRGs. The resultant SRG-RCWA algorithm can be used to exactly analyze SRGs that have grating parameters that match the Fourier expansion represented by the sampling lattice. SRGs that do not fall in this category can often still be closely approximated with our approach. The SRG-RCWA algorithm has been successfully applied to the characterization of two fabricated SRGs that are designed to function as circular polarization filters for an IR imaging polarimetry system. The agreement between numerical SRG-RCWA results and experimental measurements demonstrates its validity and usefulness.