## 2 Trajectory Fitting Based on the NURBS Curve  
In this section, according to the given NC codes, all the control points of NURBS are solved, which provides the necessary mathematical model for the interpolation of parametric curves. The basic settings are as follows:  
(1) Considering the stability, ease of use and calculation efficiency, cubic NURBS is employed as the fitting tool. (2) The uniform parametric method is used for trajectory fitting, because the polishing elements have a large radius of curvature and the chord lengths between NC codes are distributed uniformly. (3) All weight factors are set to 1. In this case, the NURBS can be treated as a cubic B-spline to simplify the calculation process. According to the basic theory of the NURBS, a segment of NURBS \(\mathbf{C}(u)(0\leq u\leq 1)\) can be determined based on the four adjacent control points \(\mathbf{d}_{k}(k=0,1,2,3)\). As shown in Figure 1, \(\mathbf{C}(0)\)and \(\mathbf{C}(1)\) separately refer to the start point and the end point of the NURBS segment. Based on the aforementioned setting, the NURBS segment can be directly written as:  
\[\mathbf{C}(u)=\frac{1}{6}\Big{[} \begin{array}{ccc}u^{3}&u^{2}&u&1\end{array}  \Big{]}\left[ \begin{array}{ccc}-1&3&-3&1\\ 3&-6&3&0\\ -3&0&3&0\\ 1&4&1&0\end{array} \right]\left[ \begin{array}{c}\mathbf{d}_{0}\\ \mathbf{d}_{1}\\ \mathbf{d}_{2}\\ \mathbf{d}_{3}\end{array} \right] \tag{1}\]  
Thus, point \(\mathbf{C}_{i}\) can be expressed as:  
\[\mathbf{C}_{i}=\frac{1}{6}(\mathbf{d}_{i-1}+4\mathbf{d}_{i}+\mathbf{d}_{i+1}) \tag{2}\]  
where \(\mathbf{C}_{i}\) denotes the \(i\)th NC code in the \(n+1\) lines of NC codes and also is taken as the start point of the \(i\)th NURBS segment. \(\mathbf{d}_{i-1},\mathbf{d}_{i},\mathbf{d}_{i+1}\) respectively denote the three control points corresponding to \(\mathbf{C}_{i}\). To calculate \(\mathbf{C}_{1}\) and \(\mathbf{C}_{n+1}\), it is defined that on the condition that \(i<1\), then \(\mathbf{d}_{i}=\mathbf{d}_{1}\) and on the condition that \(i>n+1\), then \(\mathbf{d}_{i}=\mathbf{d}_{n+1}\). Equations (3) and (4) can thus be obtained:  
\[\mathbf{C}_{1}=\frac{1}{6}(\mathbf{d}_{1}+4\mathbf{d}_{1}+\mathbf{d}_{2})=\frac{5}{6}\mathbf{d}_{1 }+\frac{1}{6}\mathbf{d}_{2} \tag{3}\]  
\[\mathbf{C}_{n+1}=\frac{1}{6}(\mathbf{d}_{n}+4\mathbf{d}_{n+1}+\mathbf{d}_{n+1})=\frac{1}{6}\bm {d}_{n}+\frac{5}{6}\mathbf{d}_{n+1} \tag{4}\]  
Rewriting Equations (2)-(4) in matrix notation yields:  
\[\mathbf{A}=\left[ \begin{array}{cccccc}5&1&0&0&0&\ldots&0\\ 1&4&1&0&0&\ldots&0\\ 0&1&4&1&0&\ldots&0\\ \vdots&\vdots&\vdots&\vdots&\vdots&\ldots&\vdots\\ 0&0&0&0&1&4&1\\ 0&0&0&0&0&1&5\end{array} \right]\mathbf{,}\mathbf{d}=\left[ \begin{array}{c}\mathbf{d}_{ 1}\\ \mathbf{d}_{2}\\ \mathbf{d}_{3}\\ \vdots\\ \mathbf{d}_{n}\\ \mathbf{d}_{n+1}\end{array} \right]\mathbf{,}\mathbf{C}=\left[ \begin{array}{c}\mathbf{6}\mathbf{ C}_{1}\\ \mathbf{6}\mathbf{C}_{2}\\ \mathbf{6}\mathbf{C}_{3}\\ \vdots\\ \mathbf{6}\mathbf{C}_{n}\\ \mathbf{6}\mathbf{C}_{n+1}\end{array} \right] \tag{5}\]  
If the traditional solution methods such as Gauss elimination method and LU decomposition are directly applied to the Equation (5), it may lead to some undesirable phenomena (such as excessive calculation time) due to the large quantity of NC codes for polishing. Hence, the SOR iterative algorithm [28] is used to find stable numerical solutions of Equation (5) as described below. The coefficient matrix \(\mathbf{A}\) can be divided into:  
\[\mathbf{A}=\mathbf{D}-\mathbf{L}-\mathbf{U} \tag{6}\]  
Figure 1: Schematic diagram of the parametric curve. where \(\mathbf{A}=\text{diag}(a_{11},a_{22},\ldots,a_{n+1n+1})\), \(-\mathbf{L}\) denotes a strictly lower triangular matrix, whose elements below the principal diagonal are corresponding elements of \(\mathbf{A}\). \(-\mathbf{U}\) denotes a strictly upper triangular matrix, whose elements above the principal diagonal are corresponding elements of \(\mathbf{A}\).