  The recently proposed concept of metagrating enables wavefront manipulation
of electromagnetic (EM) waves with unitary efficiency and relatively simple
fabrication requirements. Herein, two-dimensional (2D) metagratings composed of
a 2D periodic array of rectangular holes in a metallic medium are proposed for
diffraction pattern control. We first present an analytical method for
diffraction analysis of 2D compound metallic metagrating (a periodic metallic
structure with more than one rectangular hole in each period). Closed-form and
analytical expressions are presented for the reflection coefficients of
diffracted orders for the first time. Next, we verify the proposed method's
results against full-wave simulations and demonstrate their excellent
agreement. As a proof of principle, two applications are presented using the
proposed analytical method. The first application is a perfect out-of-plane
reflector that transfers a normal transverse-magnetic (TM) polarized plane wave
to an oblique transverse-electric (TE) polarized plane wave in the $y-z$ plane.
The second one is a five-channel beam splitter with an arbitrary power
distribution between channels. Using the proposed analytical method, we
designed these metagratings without requiring even a single optimization in a
full-wave solver. The performance of the designed metagratings is better than
previously reported structures in terms of power efficiency and relative
distribution error. Our analytical results reveals that 2D metagratings can be
used for manipulating EM waves in the plane and out of the plane of incidence
with very high efficiency, thereby leading to extensive applications in a wide
range of frequencies from microwave to terahertz (THz) regimes.
