## 2 System Principle
### Double-Light Positioning Algorithm
\[p_{k}=\sqrt{i_{k}^{2}+j_{k}^{2}} \tag{4}\]  
The distance between the LED pixels is:  
\[p_{12}=\sqrt{\left(i_{1}-i_{2}\right)^{2}+\left(j_{1}-j_{2}\right)^{2}} \tag{5}\]  
The physical distance between the two LEDs can be expressed as:  
\[d_{12}=\sqrt{\left(x_{1}-x_{2}\right)^{2}+\left(y_{1}-y_{2}\right)^{2}} \tag{6}\]  
The vertical distance between the LED and the lens plane can be expressed as:  
\[H=f\frac{d_{12}}{p_{12}} \tag{7}\]  
The \(Z_{c}\) coordinate of the terminal can be located:  
\[Z_{c}=z_{1}-H=z_{2}-H \tag{8}\]  
Thus, when the image coordinate system and the world coordinate system are parallel and have the same direction, the coordinate of the terminal in the camera system can be obtained according to the geometric relationship of similar triangles:  
\[\frac{X_{c}-\frac{x_{1}+x_{2}}{2}}{H}=\frac{\frac{i_{1}+j_{2}}{2}}{f} \tag{9}\]  
\[\frac{Y_{c}-\frac{y_{1}+y_{2}}{2}}{H}=\frac{\frac{i_{1}+j_{2}}{2}}{f} \tag{10}\]  
However, Equations (9) and (10) only present the relationship between the image coordinate and the world coordinate. If the image coordinate system and the world coordinate system are parallel and have the same direction, \((X_{c},Y_{c},Z_{c})=(X_{w},Y_{w},Z_{w})\). However, under normal circumstances, there is no parallel relationship between the camera coordinate system and the world coordinate system. When the positioning image coordinate and the world coordinate system are not parallel, the results solved from Equations (9) and (10) cannot be used as the final result. Thus, a rotation angle \(\theta\), which is the angle between the world coordinate system and the camera coordinate system, should be introduced to solve the problem. Without loss of generality, as shown in Figure 5, we assume that the vector from the centroid of light source A to that of light source B is parallel to the axis \(X_{c}\). Thus, the vector from the projective point B' to the projective point A' is also parallel to axis \(X_{c}\), and the orientation \(\theta\) of the receiver can be estimated by calculating the angle \(\theta\) between the vector of B'A' and the axis \(X_{w}\). Rotation angle of the positioning terminal can be obtained from a captured image of the LED lightings and it can be expressed as  
\[\theta=\text{atan2}\bigg{(}j_{1}-\frac{j_{1}+j_{2}}{2},i_{1}-\frac{i_{1}+i_{2 }}{2}\bigg{)}=\text{atan2}(j_{1}-j_{2},i_{1}-i_{2}) \tag{11}\]  
Figure 3:0 The transformation model of camera coordinate system and the world coordinate system. In our proposed algorithm, we put forward a method to find the true rotation angle \(\varphi\) by classified discussion. Figure 6 shows the different situations when the rotation angle \(\varphi\) change from 0 to \(360^{\circ}\) respectively, and \(\theta\) is in a range of \(\left[0,\ 90^{\circ}\right]\). In Figure 6a-e, \(\varphi\) are 0, \(\theta,\ \theta+90^{\circ},\ \theta+180^{\circ}\) and \(360^{\circ}-\theta\), respectively. Then, by rotating the image according to the obtained rotation angle, the image can be made parallel and equal to the coordinate axis. Therefore, we can rotate the coordinate by Equation (12) and realize positioning under any azimuth. \[\left[ \begin{array}{c}X_{w}\\ Y_{w}\\ Z_{w}\end{array} \right]=\left[ \begin{array}{ccc}cos\varphi&-sin\varphi&0\\ sin\varphi&cos\varphi&0\\ 0&0&1\end{array} \right]\left[ \begin{array}{c}X_{c}\\ Y_{c}\\ Z_{c}\end{array} \right] \tag{12}\]  
where (\(X_{c}\), \(Y_{c}\), \(Z_{c}\)) is the coordinate in the image sensor coordinate system and (\(X_{w}\), \(Y_{w}\), \(Z_{w}\)) is the coordinate in the world coordinate system. Although the authors of [16] proposed a positioning method based on two LEDs, they did not offer a specific positioning progress, which causes much confusion and suspicion. Meanwhile, we specifically explain how we determine the receiver's position in the above introduction of our algorithm. Besides, they did not take the symmetry problem of angle into consideration, which we have explained.