# Cooperative Localization Using Distance Measurements for Mobile Nodes
## 3 Resolving Rotation and Flip Ambiguities
### Analysis of Rotation Ambiguity
If we break the analysis of (13) into three parts, then we have the following:  
1. Since only the lead node's position is changed, then the term \(\mathbf{D}-\mathbf{D}^{\prime}\) in (13) becomes \[\mathbf{D}-\mathbf{D}^{\prime}= \begin{bmatrix}0&d_{1,2}^{2}-d_{1,2}^{\prime \,2}&\cdots&d_{1,n}^{2}-d_{1,n}^{\prime\,2}\\ d_{1,2}^{2}-d_{1,2}^{\prime\,2}&0&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ d_{1,n}^{2}-d_{1,n}^{\prime\,2}&0&\cdots&0\end{bmatrix} .\] (14)
2. In (13), \(\Delta\mathbf{D}\) is the distance matrix between point \(\Delta\mathbf{\mathcal{S}}_{1}\) and \(n-1\) origin points \([0,0]^{T}\), i.e., \[\Delta\mathbf{D}^{\prime}= \begin{bmatrix}0&\Delta{x_{1}^{\prime\,2}}^{2}+ \Delta{y_{1}^{\prime\,2}}^{2}&\cdots&\Delta{x_{1}^{\prime\,2}}^{2}+\Delta{y_{ 1}^{\prime\,2}}^{2}\\ \Delta{x_{1}^{\prime\,2}}^{2}+\Delta{y_{1}^{\prime\,2}}^{2}&0&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ \Delta{x_{1}^{\prime\,2}}^{2}+\Delta{y_{1}^{\prime\,2}}^{2}&0&\cdots&0\end{bmatrix} .\] (15)For the term \(-2\Delta\mathbf{\mathcal{S}}^{\prime T}\mathbf{\mathcal{S}}-2\mathbf{\mathcal{S}}^{T}\Delta \mathbf{\mathcal{S}}^{\prime}\) in (13), since \(\mathbf{\mathcal{S}}^{T}\Delta\mathbf{\mathcal{S}}^{\prime}\) can be calculated by  
\[\mathbf{\mathcal{S}}^{T}\Delta\mathbf{\mathcal{S}}^{\prime}= \begin{bmatrix}0&0\\ x_{2}&y_{2}\\ x_{3}&y_{3}\\ \vdots&\vdots\\ x_{n}&y_{m}\end{bmatrix}\begin{bmatrix}\Delta x_{1}^{\prime}&0&0&\cdots&0\\ \Delta y_{1}^{\prime}&0&0&\cdots&0\\ \end{bmatrix} = \begin{bmatrix}0&0&\cdots&0\\ x_{2}\Delta x_{1}^{\prime}+y_{2}\Delta y_{1}^{\prime}&0&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ x_{n}\Delta x_{1}^{\prime}+y_{n}\Delta y_{1}^{\prime}&0&\cdots&0\end{bmatrix} , \tag{16}\]  
therefore  
\[-\left(2\Delta\mathbf{\mathcal{S}}^{\prime T}\mathbf{\mathcal{S}}+2\mathbf{\mathcal{S}}^{ T}\Delta\mathbf{\mathcal{S}}^{\prime}\right)=-2\bigg{(}\Big{(}\mathbf{\mathcal{S}}^{T} \Delta\mathbf{\mathcal{S}}^{\prime}\Big{)}^{T}+\mathbf{\mathcal{S}}^{T}\Delta\mathbf{ \mathcal{S}}^{\prime}\bigg{)}. \tag{17}\]  
Inserting the rotation (8) into \(x_{i}\Delta x_{1}^{\prime}+y_{i}\Delta y_{1}^{\prime}\) in (16), for \(i=2,\ldots,n\), we have  
\[x_{i}\Delta x_{1}^{\prime}+y_{i}\Delta y_{1}^{\prime} =x_{i}^{*}\Delta x_{1}^{\prime}\cos(\theta)+y_{i}^{*}\Delta x_{1} ^{\prime}\sin(\theta)+y_{i}^{*}\Delta y_{1}^{\prime}\cos(\theta)-x_{i}^{*} \Delta y_{1}^{\prime}\sin(\theta)\] \[=(x_{i}^{*}\Delta x_{1}^{\prime}+y_{i}^{*}\Delta y_{1}^{\prime}) \cos(\theta)+(y_{i}^{*}\Delta x_{1}^{\prime}-x_{i}^{*}\Delta y_{1}^{\prime}) \sin(\theta). \tag{18}\]  
Using (18) allows us to express (17) in a way that is independent of \([x_{i},\ y_{i}]^{T}\). If we combine (14)-(18), then (13) becomes  
\[\mathbf{\mathcal{D}}-\mathbf{\mathcal{D}}^{\prime}+\Delta\mathbf{\mathcal{D}}^{\prime}-2 \Delta\mathbf{\mathcal{S}}^{\prime T}\mathbf{\mathcal{S}}-2\mathbf{\mathcal{S}}^{T}\Delta \mathbf{\mathcal{S}}^{\prime}= \begin{bmatrix}0&f_{2}(\theta)&\cdots&f_{n}(\theta) \\ f_{2}(\theta)&0&\cdots&0\\ \vdots&\vdots&\ddots&\vdots\\ f_{n}(\theta)&0&\cdots&0\end{bmatrix} =\mathbf{0}, \tag{19}\]  
where  
\[f_{i}(\theta)=a_{i}+b_{i}\cos(\theta)+c_{i}\sin(\theta),\qquad\qquad i=2, \ldots,n \tag{20}\]  
with coefficients  
\[a_{i} =d_{1,i}^{2}-{d^{\prime}}_{1,i}^{2}+\Delta{x^{\prime}}_{1}^{2}+ \Delta{y^{\prime}}_{1}^{2} \tag{21}\] \[b_{i} =-2(x_{i}^{*}\Delta x_{1}^{\prime}+y_{i}^{*}\Delta y_{1}^{\prime})\] (22) \[c_{i} =2(x_{i}^{*}\Delta y_{1}^{\prime}-y_{i}^{*}\Delta x_{1}^{\prime}) \tag{23}\]  
Equation (19) is equivalent to the following system of equations:  
\[ \begin{cases}a_{2}+b_{2}\cos(\theta)+c_{2}\sin(\theta)=&0\\ \vdots&\vdots\\ a_{n}+b_{n}\cos(\theta)+c_{n}\sin(\theta)=&0\end{cases} , \tag{24}\]  
Finally, the solution to (24) is the angle to resolve the rotation ambiguity. Importantly, this solution can be shown to be unique when \(n\geq 3\). If we consider the case of \(n=3\), then (24) can be expressed as  
\[