# Gear Integrated Error Determination Using the Gaussian Template Convolution-Facet Method
## 4 Obtaining Gear Integrated Error Based on GTC\(-\)Facet
### Accurate Positioning of the Center Point of the Gear End Face  
The center point of the gear end face is the basis for accurately calculating a series of gear accuracy detection items such as radial composite deviation, pitch deviation, and profile deviation, so it is necessary to first locate the gear center during measurement. The center of a gear can be fitted by the tip circle, root circle, or center hole circle. However, compared to the tip and root, the center hole is usually used as a fitting hole to be integrated with the output shaft or bearing. The size tolerance and cylindricity of the center hole reflect the performance of the gear, so the center hole is used to fit the gear center here.  
The GTC\(-\)Facet sub-pixel fitting algorithm is used to extract the contour of the center hole, and the least squares method is used to fit the center of the circle. However, considering that using visual methods to measure and extract the gear contour is highly susceptible to dust interference and outliers, the least squares method is not reliable enough for outliers and may result in significant calculation errors. Therefore, this article adopts an iterative reweighted least squares method to improve the accuracy of circle fitting. Firstly, the coordinate formula for a circle is as follows:  
\[\left(x-x_{0}\right)^{2}+\left(y-y_{0}\right)^{2}=r^{2} \tag{23}\]  
\(\left(x_{0},y_{0}\right)\) and \(r\) are the center and radius of the fitted circle, respectively. Assuming that there are \(n\) extracted center hole edge points, and the coordinates of each sub-pixel contour point are \(\left(x_{i},y_{i}\right)\), \(i=1\)-\(n\). The optimization objective function for the square of its error can be expressed as follows:  
\[S=\sum_{i=1}^{n}\left(x_{i}^{2}-2x_{0}x_{i}+x_{0}^{2}+y_{i}^{2}-2y_{0}y_{i}+y_ {0}^{2}-r^{2}\right)^{2} \tag{24}\]  
Where  
\[b_{1}=-2x_{0},b_{2}=-2y_{0},b_{3}=x_{0}^{2}+y_{0}^{2}-r^{2} \tag{25}\]  
Figure 5: Gear sub-pixel contour extraction method based on GTC\(-\)Facet model.  
After introducing distance weights \(w_{i}\) for each sub-pixel contour point \((x_{i},y_{i})\), Equation (24) will be rewritten as follows:  
\[S=\sum_{i=1}^{n}w_{i}(x_{i}^{2}+y_{i}^{2}+b_{1}x_{i}+b_{2}y_{i}+b_{3})^{2} \tag{26}\]  
The ultimate goal of the iterative reweighted least squares method is to achieve a minimum value for the objective function \(S\). At this point, simply take the partial derivatives of coefficient \(b_{1}\), \(b_{2}\), and \(b_{3}\) separately, and make all partial derivatives zero to obtain the coefficients of the objective function. However, for Equation (26), the distance from each point to the center of the circle cannot be determined until the coefficients are fitted, so weights cannot be assigned. Therefore, iterative methods need to be used to solve the problem. In the first iteration, the standard least squares method is used to fit the circle, i.e., \(w_{i}=1\). In the \(2-n\) iterations, the weight function proposed by [PERSON] is used:  
\[w(\delta)=\left\{\begin{array}{ll}1,&\delta\leq\gamma\\ \gamma/\delta&\delta>\gamma\end{array}\right. \tag{27}\]  
In the equation, parameter \(\gamma\) is the clipping function, which defines which points are outliers. The \(\delta\) independent variable of the function represents the distance from a point to the center of a circle. After multiple iterations, calculate the optimal coefficients \(b_{1}\), \(b_{2}\), and \(b_{3}\), and substitute them into Equation (26) to calculate the best fitting center and radius:  
\[x_{0}=-\frac{b_{1}}{2},y_{0}=-\frac{b_{2}}{2},r=\frac{1}{2}\sqrt{b_{1}^{2}+b_ {2}^{2}-4b_{3}} \tag{28}\]  
Figure 6 shows the result of fitting the center and radius of the gear center hole using the iterative reweighted least squares method. Similarly, the tip circle and root circle can also be calculated using the method of fitting the center hole circle.