# AOA-Based Three-Dimensional Multi-Target Localization in Industrial WSNs for LOS Conditions
## 4 Multi-Target Detection and Localization
### Localization of MSNs  
As shown in the network model of Figure 1, the target MSN, \(\mathcal{M}_{k}\), should be on the line through \(\mathcal{A}_{i}\) with the direction of \((\tilde{\phi}_{i,k,1},\tilde{\theta}_{i,k,1})\) in the spherical coordinate system \(\mathbb{C}_{i}\) where \(i=1,2\) for the two ANs. The two lines are denoted by \(f_{i,k}(x,y,z)_{C_{N}}\) in the common network coordinate system, \(\mathbb{C}_{N}\). Ideally, \(\mathcal{M}_{k}\) is located at the intersection of \(f_{1,k}\) and \(f_{2,k}\). However, in practical environments, the two lines may have no point of intersection (not in the same plane) due to measurement errors caused by noise and interference, and they are _skew lines_. How to determine the position of \(\mathcal{M}_{k}\) according to 3D Euclidean geometry is described below.  
At first, we convert the definitions of the two lines from the spherical coordinate systems (for AOA estimation) to the network orthogonal coordinate system (for target localization). The intersection between the line \(f_{i,k}(x,y,z)_{C_{N}}\) and the unit sphere is denoted by \(\mathbf{P}_{i,k}\). In \(\mathbb{C}_{i}\), the coordinate of \(\mathbf{P}_{i,k}\) is  
\[\mathbf{P}_{C_{i},i,k}=\begin{bmatrix}x_{C_{i}P_{i}}\\ y_{C_{i}P_{i}}\\ z_{C_{i}P_{i}}\end{bmatrix}=\begin{bmatrix}\sin\theta_{i,k,1}\cos\phi_{i,k,1} \\ \sin\theta_{i,k,1}\sin\phi_{i,k,1}\\ \cos\theta_{i,k,1}\end{bmatrix}. \tag{15}\]  
Thus, the coordinates of \(\mathbf{P}_{i,k}\) in \(\mathbb{C}_{N}\) are \(\mathbf{P}_{C_{N},i,k}=\mathbf{P}_{C_{i},i,k}+\mathbf{A}_{C_{N},i}\), where \(\mathbf{A}_{C_{N},i}\) are the coordinates of \(\mathcal{A}_{i}\) in \(\mathbb{C}_{N}\). Consequently, the two lines are defined by the two pairs of points, \(\mathbf{A}_{C_{N},i}\) and \(\mathbf{P}_{C_{N},i,k}\), in \(\mathbb{C}_{N}\) for \(i=1,2\).  
The two pairs of points define a tetrahedron in 3D space as the four vertices. The volume of the tetrahedron is  
\[V=\frac{1}{6}\left|\det\begin{bmatrix}\mathbf{P}_{C_{N},1,k}-\mathbf{A}_{C_{ N},1}\\ \mathbf{A}_{C_{N},1}-\mathbf{A}_{C_{N},2}\\ \mathbf{A}_{C_{N},2}-\mathbf{P}_{C_{N},2,k}\end{bmatrix}\right|, \tag{16}\]  
where \(\det[\cdot]\) is the determinant. The relationship between the two lines is discussed in the following two cases.  
* If the volume of the tetrahedron is zero (i.e., \(V=0\)), the two lines are coplanar and have an intersection. The intersection point can be easily determined by \(f_{i,k}(x,y,z)_{C_{N}}\) in the plane.
* If the volume of the tetrahedron is nonzero (i.e., \(V>0\)), \(f_{1,k}\) and \(f_{2,k}\) are skew lines without intersection. The points on the line segment perpendicular to both lines have the minimum sum of distances to \(f_{1,k}\) and \(f_{2,k}\). Hence, the MSN position is approximated by the midpoint of the line segment. First, we define the direction vectors of the two lines by \(\mathbf{D}_{C_{N},i,k}=\mathbf{P}_{C_{N},i,k}-\mathbf{A}_{C_{N},i}\) for \(i=1,2\). Thus, the two lines can be expressed as \(\mathbf{Q}_{C_{N},i,k}=\mathbf{A}_{C_{N},i}+\lambda_{i  
\[\mathbf{Q}_{C_{N},2,k}^{*}=\mathbf{P}_{C_{N},2,k}+\frac{\left(\mathbf{P}_{C_{N},1,k }-\mathbf{P}_{C_{N},2,k}\right)\cdot\mathbf{V}_{C_{N},1}}{\mathbf{D}_{C_{N},2} \cdot\mathbf{V}_{C_{N},1}}\times\mathbf{D}_{C_{N},2}, \tag{18}\]  
where \(\mathbf{V}_{C_{N},1}=\mathbf{D}_{C_{N},1}\times\left(\mathbf{D}_{C_{N},2} \times\mathbf{D}_{C_{N},1}\right)\). Thus, \(\mathbf{Q}_{C_{N},1,k}^{*}\) and \(\mathbf{Q}_{C_{N},2,k}^{*}\) form the shortest line segment joining \(f_{1,k}\) and \(f_{2,k}\). Finally, the location of \(\mathcal{M}_{k}\) can be determined as  
\[\mathbf{P}_{C_{N},M_{k}}=\frac{\mathbf{Q}_{C_{N},1,k}^{*}+\mathbf{Q}_{C_{N},2,k}^{*}}{2}. \tag{19}\]  
Since we have determined the coordinates of the target MSN, the distance \(d_{i,k}\) is readily calculated from its coordinate.