## 3 Positioning Model Establishment and Solution
### Triangular Centroid Position Algorithm
#### 3.1.2 Improved Triangular Centroid Position Algorithm  
According to the principle of the traditional weighted centroid position algorithm, the weight part plays a crucial role in the positioning accuracy of the whole algorithm, and the reasonable selection of the weight value can avoid the phenomenon of information flooding. Different methods can be used for weight selection in the weighted centroid positioning algorithm. In this paper, the square sum of the distance is used to replace the algorithm of the reciprocal of the distance sum in the traditional algorithm. First, the received distance data is cleaned by 3\(\sigma\) criteria to remove interference points. Then, draw a circle with the three anchor points as the center and the distance between the unknown node and the beacon node as the radius. Since the actual measurement results have errors every time, the three circles will not intersect at one point but will produce common intersections, as shown in Figure 5b. At this point, the unknown node is positioned at the intersection of all circles.  
Based on the centroid algorithm mentioned above, the triangle formed by the common intersection (ABC) of the three circles is analyzed, and the distance between the preferred reference node and the unknown node is used to add a weight to each coordinate to reflect the difference. Among vertex contribution, (x\({}_{A}\), y\({}_{A}\)), (x\({}_{B}\), y\({}_{B}\)), (x\({}_{C}\), y\({}_{C}\)) are the coordinates of the three intersection points, which can be easily obtained. Not only is the RSSI data information added to the centroid operation, but the weight selection is also reasonably arranged. The information weight is adopted, and the concept of the correction coefficient is adopted so that the whole positioning accuracy has been greatly improved. However, in the actual test, the three circles often cannot meet at one point due to range error. Assuming that the mobile node is only active in the area of the reference node, the possible situation is shown in Figure 5.  
Figure 5: Four possible situations in trilateration calculation ((**a–d**) present different positions).  
In actual operation, it is first necessary to determine how many of the three circles intersect. The method used can be to combine the equations of the three circles in pairs to determine whether there is a solution:  
\[\begin{cases}(x-x_{1})^{2}+(y-y_{1})^{2}=r_{1}{}^{2}\\ (x-x_{2})^{2}+(y-y_{2})^{2}=r_{2}{}^{2}\end{cases} \tag{3}\]  
\[\begin{cases}(x-x_{1})^{2}+(y-y_{1})^{2}=r_{1}{}^{2}\\ (x-x_{3})^{2}+(y-y_{3})^{2}=r_{3}{}^{2}\end{cases} \tag{4}\]  
\[\begin{cases}(x-x_{2})^{2}+(y-y_{2})^{2}=r_{2}{}^{2}\\ (x-x_{3})^{2}+(y-y_{3})^{2}=r_{3}{}^{2}\end{cases} \tag{5}\]  
If Equation (3) has solutions (x\({}_{12}\), y\({}_{12}\)) and (x\({}_{21}\), y\({}_{21}\)), determine which point is close to the point (x\({}_{3}\), y\({}_{3}\)), and select this point as point D; if equation has solutions (x\({}_{13}\), y\({}_{13}\)) and (x\({}_{31}\), y\({}_{31}\)), determine which point is close to the point (x\({}_{2}\), y\({}_{2}\)), and select this point as point F; if Equation (5) has a solution (x\({}_{23}\), y\({}_{23}\)) And (x\({}_{32}\), y\({}_{32}\)), determine which point is close to the point (x\({}_{1}\), y\({}_{1}\)), and select this point as point E, then the center of gravity of \(\Delta\)DEF is the position of the mobile node we need to position. If there is no solution to Equation (3), the center of the two circles connecting the two circles, and the center of the two points where the circle intersects is point D; if Equations (4) and (5) have no solution, the coordinates of points E and F will be obtained in the same way. So, we can get 3 points D, E, and F regardless of whether the circles intersect or not, and get the coordinates of the moving node by finding the center of gravity.