# Cooperative Localization Using Distance Measurements for Mobile Nodes
## 3 Resolving Rotation and Flip Ambiguities
### Analysis of Rotation and Flip Ambiguities  
Having obtained a unique solution to the rotation angle when only rotation ambiguity is present, in this section we present an analytical solution that is based on the analysis in Section 3.1 for when rotation and flip ambiguities occur simultaneously. The key idea behind this method is again to use the mobility of the lead node to acquire extra information in order to detect the flip of the initial MDS localization result. Firstly, we assume that there exist three non-collinear nodes in order to be able to detect flip ambiguity. Next, we note that the \(i\)th equation in (24) has the following solutions \(\theta_{i,1}\) and \(\theta_{i,2}\):  
\[\theta_{i,1,2}=\text{atan2}\bigg{(}a_{i}b_{i}\pm|c_{i}|\sqrt{b_{i}^{2}+c_{i}^{ 2}-a_{i}^{2}},\quad a_{i}c_{i}\mp\frac{b_{i}}{c_{i}}|c_{i}|\sqrt{b_{i}^{2}+c_{i }^{2}-a_{i}^{2}}\bigg{)}, \tag{26}\]  
where \(\text{atan2}(\cdot,\cdot)\in[-\pi,\pi)\) is the 2-argument arctangent. Therefore, the solution to (26), which is common to all values of \(i\), \(\forall i=2,\ldots,n\) is the unique solution to (24). It can also be shown that \(\theta_{i,1,2}\in[-\pi,\pi)\) given in (26) can be rewritten and rearranged into a concise form  
\[\theta_{i,1} =g\Big{(}\text{atan2}(y_{i}^{*},x_{i}^{*})-\text{atan2}(y_{i},x_{ i})\Big{)} \tag{27}\] \[\theta_{i,2} =g\Big{(}\theta_{i,1}+2\Theta_{i}\Big{)} \tag{28}\]  
where \(\Theta_{i}=\text{atan2}(y_{i},x_{i})+\text{atan2}\big{(}\Delta x_{1}^{\prime}, \Delta y_{1}^{\prime}\big{)}-\frac{\pi}{2}\) and the function \(g(t)=t-2\pi\Big{\lfloor}\frac{t}{2\pi}+\frac{1}{2}\Big{\rfloor}\) can wrap any arbitrary angle \(t\) in radians into range \([-\pi,\pi)\). Appendix A provides the full derivation of these equations. The angles \(\theta_{i,1}\) in (27) represent the angles between vectors \(\overrightarrow{\mathbf{\mathcal{S}_{1}}\mathbf{\mathcal{S}_{i}}}\) and \(\overrightarrow{\mathbf{\mathcal{S}_{1}}\mathbf{\mathcal{S}_{i}}}\) for \(i=2,\ldots,n\), as shown in Figure 2, and play an important role in the ability to detect flip ambiguity. When there is only rotation ambiguity, because of the uniqueness of solution of (24), we have \(\theta_{i,1}=\theta_{j,1}\), \(\forall i,j=2,\ldots,n\), as shown in the previous section. Whereas, the angles \(\theta_{i,2}\) in (28) are the summation of \(\theta_{i,1}\) and the angle induced by \(\Delta x_{1}^{\prime}\) and \(\Delta x_{2}^{\prime}\). Obviously, if there exist three non-collinear nodes, \(\Theta_{i}\
eq\Theta_{j}\), \(\forall i,j=2,\ldots,n\) and \(i\
eq j\) and, therefore, from (28) we have \(\theta_{i,2}\
eq\theta_{j,2}\), \(\forall i,j=2,\ldots,n\). In contrast, it can be shown that flip ambiguity exists if and only if \(\theta_{i,1}\
eq\theta_{j,1}\), \(\forall i,j=2,\ldots,n\) and \(i\
eq j\). In order to illustrate why this is the case, we give the counter example, assuming without loss of generality, that \(n=3\), \(\theta_{2,1}=\theta_{3,1}\) and flip ambiguity exists. \(\theta_{2,1}=\theta_{3,1}\) implies that \(\mathbf{\mathcal{S}_{i}^{*}}\), \(i=2,3\), can be rotated simultaneously to the true positions \(\mathbf{\mathcal{S}_{i}}\) via either \(\theta_{2,1}\) or \(\theta_{3,1}\), as shown in Figure 1(a). Hence, this contradicts the assumption of the existence of flip ambiguity. Figure 2: Illustration of angle \(\theta_{i,1}\) given in (27) using three nodes with true locations \(\mathbf{s}_{i}\) and solved ambiguous locations \(\mathbf{s}_{i}^{*}\). (**a**) rotation ambiguity and \(\theta_{2,1}=\theta_{3,1}\); (**b**) flip ambiguity and \(\theta_{2,1}\
eq\theta_{3,1}\). Furthermore, extending to the case where \(n>3\), still assuming that \(\theta_{2,1}=\theta_{3,1}\) and flip ambiguity exists. We know that, for \(i=2,3\), \(\mathbf{\mathcal{S}}_{i}^{*}\) can be simultaneously rotated to the true positions \(\mathbf{\mathcal{S}}_{i}\) via \(\theta_{2,1}\) (or \(\theta_{3,1}\)). Because there exist three non-collinear nodes, then three nodes with correct positions are sufficient for guaranteeing the localization of the whole network [39].