## 2 Design of the Angle Detector Based on Grating Coupling  
Schematic of the grating-based angle detector is depicted in Figure 1. It is completely planar and composed of four layers. The top layer is \"grating layer,\" which consists of N grating elements. The grating elements are considered uniform and infinitely long along \(y\) direction in our modeling; and, they are deployed periodically along \(x\) direction with periodicity \(\Lambda\). The grating layer sits on top of an SOI slab waveguide. A laser beam with frequency \(f_{inc}\) is incident onto the device from the top. The incident direction is in the \(x\)-\(z\) plane. The angle between the incident laser and z direction (_i.e._, surface normal direction) is denoted as \(\theta_{inc}\). When the laser is incident obliquely, \(\theta_{inc}\) takes positive values when the incident laser is along \(+x\) direction and \(\theta_{inc}\) is negative when the incident laser is along \(-x\) direction. Our device is designed such that the incident light is efficiently coupled to the \"\(+x\) traveling mode\" and \"\(-x\) traveling mode\" in the slab waveguide. When \(\theta_{inc}=0\) (that is, normal incidence), \"\(+x\) mode\" and \"\(-x\) mode\" in the slab waveguide are equally strong, due to the geometrical symmetry. When \(\theta_{inc}\
eq 0\) (that is, oblique incidence), the \"\(+x\) mode\" and \"\(-x\) mode\" are unbalanced. As a result, \(\theta_{inc}\) can be found by comparing the \"\(+x\) mode\" and \"\(-x\) mode.\" In our device, the \"\(+x\) mode\" and \"\(-x\) mode\" are observed by placing two detectors in the slab waveguide. The two detectors are named \"\(+x\) detector\" and \"\(-x\) detector,\" respectively. The \"\(+x\) detector\" is placed to the right of the grating structure and it serves to detect the power of the \"\(+x\) mode;\" similarly, the \"\(-x\) detector\" is placed to the left of the grating structure and it detects the power of the \"\(-x\) mode.\" The photodetectors in the waveguide can be implemented by following available architectures in [16, 17, 18]. In Figure 2, typical spectral outputs of the \"\(+x\) detector\" are illustrated with various \(\theta_{inc}\) values. In our design, the incident light is coupled to the waveguide modes via the second-order Floquet mode predominantly. Consequently, transverse resonance occurs when the following condition is satisfied  
\[k_{inc}\sin\theta_{inc}+2\frac{2\pi}{\Lambda}=k_{x}^{\text{wg}} \tag{1}\]  
In the above equation, \(k_{inc}=2\pi f_{inc}/c\), \(c\) is the speed of light in free space, and \(k_{x}^{\text{wg}}\) is the wavenumber along \(x\) for the fundamental guided mode in the slab waveguide. It is noted that \(k_{x}^{\text{wg}}\) is non-linear with respect to the frequency. The transverse resonant frequency for \(\theta_{inc}=0\) is denoted as \"\(f_{0}\).\" The transverse resonant frequency increases with the increase of \(\theta_{inc}\), as shown in Figure 2. Bandwidth of the resonance is measured by finding the frequencies at which the photodetector's output drops by 3 dB with respect to the value at the resonant frequency. Further, quality factor is defined as the ratio between the resonant frequency and the bandwidth. In our design, \(f_{0}\) is chosen to be close to \(f_{inc}\) and greater than \(f_{inc}\); and, the offset between \(f_{0}\) and \(f_{inc}\) is characterized by  
\[\Delta_{f}=\frac{f_{0}-f_{inc}}{f_{0}} \tag{2}\]  
Figure 1: **(a)** The device schematic. (**b**) The cross-section view in the \(x\)–\(z\) plane. Output of the \"\(+x\) detector\" varies with respect to \(\theta_{inc}\) when \(f_{inc}\) is a constant frequency. Meanwhile, output of the \"\(-x\) detector\" exhibits variation with respect to \(\theta_{inc}\) as well.