# Cooperative Localization Using Distance Measurements for Mobile Nodes
## Appendix A  
**Proposition A1**.: _Function \(g(t)=t-2\pi\Big{\lfloor}\frac{t}{2\pi}+\frac{1}{2}\Big{\rfloor}\) can wrap arbitrary angle \(t\) in radians into range \([-\pi,\pi)\) and it satisfies following properties: P.1 \(g(t_{1}\pm t_{2})=g(g(t_{1})\pm g(t_{2}))\); and P.2 \(g(-t)=-g(t)\)._  
**Lemma A1**.: _Let \(g(t)=t-2\pi\Big{\lfloor}\frac{t}{2\pi}+\frac{1}{2}\Big{\rfloor}\), then_  
\[\mathrm{atan2}(\beta_{1}\alpha_{2}\pm\beta_{2}\alpha_{1},\ \alpha_{1}\alpha_{2}\mp \beta_{1}\beta_{2})=g(\mathrm{atan2}(\beta_{1},\alpha_{1})\pm\mathrm{atan2}( \beta_{2},\alpha_{2})),\] (A1)  
From (21)-(23), we have  
\[a_{i} =d_{1,i}^{2}-d_{1,i}^{\prime\,2}\pm\Delta{x_{1}}^{2}+\Delta{y_{1} }^{2}\] \[=\Big{(}x_{i}^{2}+y_{i}^{2}\Big{)}-\Big{(}(x_{i}-\Delta x_{1}^{ \prime})^{2}+(y_{i}-\Delta y_{1}^{\prime})^{2}\Big{)}+\Delta{x_{1}}^{\prime \,2}+\Delta{y_{1}}^{\prime\,2}\] \[=2\big{(}x_{i}\Delta x_{1}^{\prime}+y_{i}\Delta y_{1}^{\prime} \big{)}\]and  
\[b_{i}^{2}+c_{i}^{2}-a_{i}^{2}= 4(x_{i}^{*}\Delta x_{1}^{\prime}+y_{i}^{*}\Delta y_{1}^{\prime})^{ 2}+4(y_{i}^{*}\Delta x_{1}^{\prime}-x_{i}^{*}\Delta y_{1}^{\prime})^{2}-4\big{(}x _{i}\Delta x_{1}^{\prime}+y_{i}\Delta y_{1}^{\prime}\big{)}^{2}\] \[= 4\Big{(}\Big{(}d_{1,i}^{2}-d_{1,i}^{2}+y_{i}^{2}\Big{)}\Delta{x_{1 }^{\prime}}^{2}+\Big{(}d_{1,i}^{2}-d_{1,i}^{2}+x_{i}^{2}\Big{)}\Delta y_{1}^{ \prime}{}^{2}-2x_{i}y_{i}\Delta x_{1}^{\prime}\Delta y_{1}^{\prime}\Big{)}\] \[= 4\big{(}x_{i}\Delta y_{1}^{\prime}-y_{i}\Delta x_{1}^{\prime} \big{)}^{2}. \tag{10}\]  
Then from Lemma 1 and (10), we have  
\[\theta_{i,1,2} =\text{atan2}\bigg{(}-a_{i}c_{i}\mp\frac{b_{i}}{c_{i}}|c_{i}| \sqrt{b_{i}^{2}+c_{i}^{2}-a_{i}^{2}},\ -a_{i}b_{i}\pm|c_{i}|\sqrt{b_{i}^{2}+c_{i}^{2}-a_{i}^{2}} \bigg{)}\] \[=-g\bigg{(}\text{atan2}(b_{i},c_{i})+\text{atan2}\bigg{(}a_{i}, \pm\frac{|c_{i}|}{c_{i}}\sqrt{b_{i}^{2}+c_{i}^{2}-a_{i}^{2}}\bigg{)}\bigg{)} \tag{11}\] \[=-g\Big{(}\text{atan2}(b_{i},c_{i})+\text{atan2}\left(a_{i},\ \pm 2 \big{(}x_{i}\Delta y_{1}-y_{i}\Delta x_{1}\big{)}\right)\Big{)}. \tag{12}\]  
From (11) to (12), the sign of \(\pm\frac{|c_{i}|}{c_{i}}\sqrt{4\big{(}x_{i}\Delta y_{1}-y_{i}\Delta x_{1}\big{)} ^{2}}\) is interpreted by \(\pm\), which implies that the values of \(\theta_{i,1}\) and \(\theta_{i,2}\) may be simply exchanged.  
Furthermore,  
\[\text{atan2}(b_{i},c_{i}) =\text{atan2}\left(-\left(x_{i}^{*}\Delta x_{1}^{\prime}+y_{i}^{ *}\Delta y_{1}^{\prime}\right),\ x_{i}^{*}\Delta y_{1}^{\prime}-y_{i}^{*} \Delta x_{1}^{\prime}\right)\] \[=-\text{atan2}\big{(}x_{i}^{*}\Delta x_{1}^{\prime}+y_{i}^{*} \Delta y_{1}^{\prime},\ x_{i}^{*}\Delta y_{1}^{\prime}-y_{i}^{*}\Delta x_{1}^{ \prime}\big{)}\] \[=g\Big{(}-\text{atan2}(y_{i}^{*},x_{i}^{*})-\text{atan2}\big{(} \Delta x_{1}^{\prime},\Delta y_{1}^{\prime}\big{)}\Big{)} \tag{13}\]  
and  
\[\text{atan2}\big{(}a_{i},\ \pm 2\big{(}x_{i}\Delta y_{1}^{\prime}-y_{i} \Delta x_{1}^{\prime}\big{)}\big{)} =g\Big{(}\text{atan2}\left(2\big{(}x_{i}\Delta x_{1}^{\prime}+y_{ i}\Delta y_{1}^{\prime}\big{)},\ \pm 2\big{(}x_{i}\Delta y_{1}^{\prime}-y_{i}\Delta x_{1}^{ \prime}\big{)}\right)\Big{)}\] \[=\begin{cases}g\Big{(}\text{atan2}(y_{i},x_{i})+\text{atan2}( \Delta x_{1}^{\prime},\Delta y_{1}^{\prime}\big{)}\Big{)}\\ g\Big{(}-\text{atan2}(y_{i},x_{i})-\text{atan2}(\Delta x_{1}^{\prime},\Delta y_{ 1}^{\prime})\Big{)}\end{cases}. \tag{14}\]  
Substituting (14) and (13) into (12) leads to  
\[\theta_{i,1} =g\Big{(}\text{atan2}(y_{i}^{*},x_{i}^{*})-\text{atan2}(y_{i},x_{ i})\Big{)}\] \[\theta_{i,2} =g\Big{(}\text{atan2}(y_{i}^{*},x_{i}^{*})+\text{atan2}(y_{i},x_{ i})+2\,\text{atan2}(\Delta x_{1}^{\prime},\Delta y_{1}^{\prime})-\pi\Big{)}\] \[=g\Big{(}\theta_{i,1}+2\Theta_{i}\Big{)}\]  
where \(\Theta_{i}=\text{atan2}(y_{i},x_{i})+\text{atan2}(\Delta x_{1}^{\prime},\Delta y _{1}^{\prime})-\frac{\pi}{2}\).