# Cooperative Localization Using Distance Measurements for Mobile Nodes
## 3 Resolving Rotation and Flip Ambiguities
### Analysis of Rotation and Flip Ambiguities
In this case, \(\mathbf{s}_{1}\), \(\mathbf{s}_{2}\) and \(\mathbf{s}_{3}\) can be found exactly from \(\theta_{2,1}\) (or \(\theta_{3,1}\)). Therefore, \(\mathbf{\mathcal{S}}_{i}\), for \(i=4,\ldots,n\), must be solvable via rotating \(\mathbf{\mathcal{S}}_{i}^{*}\) by angle \(\theta_{2,1}\) (or \(\theta_{3,1}\)) and, as a result, \(\theta_{i,1}=\theta_{2,1}=\theta_{3,1}\). This again contradicts the assumption of existence of flip ambiguity. On the other hand, if \(\theta_{i,1}\
eq\theta_{i,1}\), \(\forall i,j=2,\cdots,n\) and \(i\
eq j\), then it is obvious that there exists flip ambiguity, since \(\mathbf{s}_{i}^{*}\) cannot be rotated to \(\mathbf{\mathcal{S}}_{i}\) simultaneously. As a conclusion, there exists flip ambiguity if and only if \(\theta_{i,1}\
eq\theta_{j,1}\), \(\forall i,j=2,\cdots,n\) and \(i\
eq j\). In what follows, we assume that there exist three non-collinear nodes and, based on the above analysis, we make the following conclusion:  
\[\forall i,j=2,\ldots,n\text{ and }i\
eq j \begin{cases}\theta_{i,1}=\theta_{j,1}( \text{equivalently }\theta_{i,2}\
eq\theta_{j,2}),&\text{If no flip ambiguity exists.}\\ \theta_{i,1}\
eq\theta_{j,1}(\text{equivalently }\theta_{i,2}=\theta_{j,2}),&\text{If flip ambiguity exists.}\end{cases}  \tag{29}\]  
Although we cannot use (27)-(29) directly to determine the existence of flip as they contain unknown true positions, those results are crucial in deriving the estimator for locations in noisy scenario. In reality, the solution to (24) is computed using \(\mathbf{\mathcal{S}}^{*}\), \(\Delta\mathbf{\mathcal{S}}^{\prime}\) and \(\mathbf{D}^{\prime}\). We denote this unique solution by \(\theta_{R}(\mathbf{\mathcal{S}}^{*},\Delta\mathbf{\mathcal{S}}^{\prime},\mathbf{D}^{ \prime})\). The same notation \(\theta_{R}(\cdot,\cdot,\cdot)\) is used to denote a rotation angle that is calculated with different variables, nonetheless, whatever the variables used, the method is the same as described above. If we denote the positions that are calculated using the rotation angle \(\theta_{R}(\mathbf{\mathcal{S}}^{*},\Delta\mathbf{\mathcal{S}}^{\prime},\mathbf{D}^{ \prime})\) as \(\mathbf{\mathcal{S}}^{**}\) we have the following result  
\[\mathbf{\mathcal{S}}^{**}=\mathbf{M}\big{(}\theta_{R}(\mathbf{\mathcal{S}}^{*},\Delta \mathbf{\mathcal{S}}^{\prime},\mathbf{D}^{\prime})\big{)}\mathbf{\mathcal{S}}^{*}= \begin{bmatrix}x_{1}^{**},&x_{2}^{**},&\cdots,x_{n}^{**}\\ y_{1}^{**},&y_{2}^{**},&\cdots,y_{n}^{**}\end{bmatrix} . \tag{30}\]  
If the lead node then moves to a second position \([\Delta x_{1}^{\prime\prime},\Delta y_{1}^{\prime\prime}]\) giving a matrix formed by true positions \(\mathbf{\mathcal{S}}^{\prime\prime}=\mathbf{\mathcal{S}}+\Delta\mathbf{\mathcal{S}}^{ \prime\prime}\), where  
\[\Delta\mathbf{\mathcal{S}}^{\prime\prime}= \begin{bmatrix}\Delta\mathbf{\mathcal{S}}_{ 1}^{\prime\prime},\Delta\mathbf{\mathcal{S}}_{2}^{\prime\prime},\ldots,\Delta\mathbf{ \mathcal{S}}_{n}^{\prime\prime}\end{bmatrix} = \begin{bmatrix}\Delta x_{1}^{ \prime\prime}&0&\cdots&0\\ \Delta y_{1}^{\prime\prime}&0&\cdots&0\end{bmatrix} . \tag{31}\]  
After obtaining a new distance matrix \(\mathbf{D}^{\prime\prime}\) at position \(\mathbf{\mathcal{S}}^{\prime\prime}\), we can solve \(\theta_{R}(\mathbf{\mathcal{S}}^{**},\Delta\mathbf{\mathcal{S}}^{\prime\prime}, \mathbf{D}^{\prime\prime})\). If \(\theta_{R}(\mathbf{\mathcal{S}}^{**},\Delta\mathbf{\mathcal{S}}^{\prime\prime}, \mathbf{D}^{\prime\prime})=0\), then there is no flip ambiguity and the true positions are \(\mathbf{\mathcal{S}}=\mathbf{\mathcal{S}}^{**}\); otherwise, we move to the process of resolving the flip ambiguity. For this, according to Definition 2, all the values in \(\mathbf{\mathcal{S}}^{*}\) along the \(x-\)axis are required to be flipped to obtain \(\mathbf{F}\mathbf{\mathcal{S}}^{*}\). Subsequently, we only need to calculate the rotation angle using \(\theta_{R}(\mathbf{F}\mathbf{\mathcal{S}}^{*},\Delta\mathbf{\mathcal{S}}^{\prime}, \mathbf{D}^{\prime})\).