## 4 Simulation Results
### SIL Design and Test Procedure  
The SIL simulation was implemented in MATLAB and cyclically ran through a specified flight trajectory created with the Gazebo tool. Each waypoint of the trajectory is represented by a vector \((y_{D},z_{D},\hat{\alpha},\hat{\beta},\hat{\gamma})^{T}\), which describes the position and orientation of the local UAV frame \(L_{u}\) with respect to the global frame \(\{G\}\). From this, the SIL computes the positions of the virtual sensors \(i\) and the corresponding magnetic measurements \(\vec{v}_{i}\) with respect to the local sensor frame \(L_{i}\) in each run. For this purpose, Equations (4) and (5) were used, where the rotation matrix was used according to the convention in Gazebo, i.e., \(R_{G}^{\hat{L}u}=R_{z}^{T}(\hat{\alpha})R_{y}^{T}(\hat{\beta})R_{z}^{T}(\hat{ \gamma})\). This corresponds to the transposed version of the definition used in this paper, i.e., \(\hat{R}_{G}^{\hat{L}u}=(R_{G}^{\hat{L}u})^{T}\). In order for the angles \(\alpha\), \(\beta\), and \(\gamma\) obtained in the test run to be compared later with the Gazebo angles \(\hat{\alpha}\), \(\hat{\beta}\), and \(\hat{\gamma}\), they must first be converted at the end of each run. This is done automatically by the SIL. To calculate the measured values \(\vec{v}_{i}\), the SIL assumes that there is a transmission line system with the arrangement described in Section 2.1; i.e., the cables are in the \(xy\)-plane at \(-y_{0}\) and \(y_{0}\). The SIL then passes the computed \(\vec{v}_{i}\) as the input values to the test procedure, which verifies the entire method described in this publication. The test procedure uses the constraints defined in Section 3.3 for navigation as a priori knowledge. It is called cyclically from the SIL until all waypoints on the flight trajectory have been passed and is divided into the following steps:  
1. Select the correct sign for the measurement values \(\vec{v}_{i}\) according to the selection criterion (27) (the SIL skips this step because it always calculates with the equivalent static current). 2. Calculate the UAV angles using Equations (9) and (10) for all possible sensor combinations and calculate the average. The results are \(\overline{\alpha}\) and \(\overline{\beta}\). The roll angle \(\overline{\gamma}\) cannot be calculated and is assumed to be zero. 3. Filter out the outliers by applying the moving median filter to the last 10 calculated values of each angle. 4. Calculate the measurement values \(\vec{V}_{i}\) referred to the global frame \(\{G\}\) via \(\vec{V}_{i}=R_{G}^{\underline{L_{u}}}(\bar{\alpha},\bar{\beta},\hat{\gamma}) \,R_{\underline{L_{u}}}^{I_{i}}\vec{v}_{i}\) from Equation (6). Calculate the signal powers \(P_{i}=|\vec{V}_{i}|\). 5. Calculate the \(y\)-coordinates \(y_{i1}\) and \(y_{i2}\) using Equation (21). Select the correct signs in Equation (24) using Theorem 3 in order to reduce the amount of possible \(z\)-solutions and calculate the \(z\)-coordinates \(z_{i1}\) and \(z_{i2}\). 7. Calculate the nodes \(\vec{p}_{i,e}\) of the original polygon referred to \(\{G\}\). They are calculated from the user-defined sensor positions \(\vec{p}_{i0}\) in \(L_{u}\) and the orientation of the UAV in \(\{G\}\), i.e., \(\vec{p}_{i,e}=R_{G}^{L_{u}}(\bar{\alpha},\bar{\beta},\bar{\gamma})\vec{p}_{i0}\). Shift the resulting polygon so that its upper left corner appears in the origin of \(\{G\}\). 8. Calculate from the determined sensor positions \(\vec{p}_{i1,2}\) all possible polygons and shift them so that their upper left corner appears in the origin of \(\{G\}\). The nodes of the \(k\)-th polygon are represented by \(\vec{p}_{i,k}\). 9. Compare all polygons with the original one. Therefore, first calculate the sum \(U_{k}\) of the least-squared errors of the corresponding polygon nodes with: \[U_{k}=\sum_{i=1}^{N}(\vec{p}_{i,e}-\vec{p}_{i,k})^{T}(\vec{p}_{i,e}-\vec{p}_{ i,k}),\] (28) where \(N\) is the number of nodes, respectively sensors. Choose the polygons of the two smallest sums.