# A Multivariate Local Descriptor Registration Method for Surface Topography Evaluation
## 2 Generation of Functional Surfaces and Point Cloud Based on STEP File
### The Division Functional Surface in STEP File  
The target surfaces in STEP are defined as functional surfaces that contain the demanded geometric features, such as matching surface and \(R\) angle. An _ADVANCED_FACE_ in a STEP file represents a functional surface that includes the type and boundary information based on boundary representation (BRep) [26]. The entity information of a surface is shown in Figure 2. A surface contains multiple edges, and the entity of an edge is divided into lines, circles, rational b-spline curves with knots and non-uniform rational b-spline (NURBS) curves, and the line matrix is defined by  
\[p=\begin{bmatrix}1&t\end{bmatrix}*\begin{bmatrix}o&d\end{bmatrix}^{T} \tag{1}\]  
where \(t\) is the length parameter of the line, \(o\) is the origin point, and \(d\) is the direction. The circle equation is expressed as  
\[p=\begin{bmatrix}1&r\cos\theta&r\sin\theta\end{bmatrix}*\begin{bmatrix}o&a&b \end{bmatrix}^{T} \tag{2}\]  
where \(r\) represents the radius, \(\theta\) represents the angle of the circle, \(o\) represents the centre of the circle, and \(a\) and \(b\) are vectors perpendicular to each other and perpendicular to the normal direction of the circle. The NURBS curve equation is given in the form  
\[\begin{split} p(k)=\frac{\sum\limits_{i=0}^{N}N_{i,m}(k)w_{i}P_{ i}}{\sum\limits_{i=0}^{N}N_{i,m}(k)w_{i}}\\ N_{i,0}(k)=\left\{\begin{array}{c}1(k_{i}\leq k\leq k_{i+1})\\ 0(others)\\ N_{i,m}(k)=\frac{(k-k_{i})N_{i,m-1}(k)}{k_{i+m}-k_{i}}+\frac{(k_{i+m+1}-k)N_{ i+1,m-1}(k)}{k_{i+m+1}-k_{i+1}},m\geq 1\end{array}\right.\end{split} \tag{3}\]  
where \(N\) represents the basis function, \(w\) represents weight, \(P\) is the control point, \(m\) is the order, and \(k\) indicates the parameter between knots.  
The analysis of circular arc is key in STEP parsing. Although the start and end points are given in the STEP file, it is necessary to convert them into angles through specific methods. Usually, the calculation of the cosine angle of two points can only get the range from 0 to \(\pi\) but lacks the range from \(\pi\) to \(2\pi\). To this end, the content of the circle calculation is given as follows:  
1. Calculating two direction vectors perpendicular to each other in the normal direction \(N\) of the circle. Selecting any one of the \(x\), \(y\), and \(z\) directions of the global coordinates  
Figure 2: The entity information of a particular functional surface in STEP file.  
and taking the cross product with \(N\). If the result is not 0, set it as direction \(a\); otherwise, choose another direction to calculate the cross-product. Keep taking \(N\) to cross \(a\) and direction \(b\), obtaining \(a\), \(b\) and \(N\) as the local coordinate system of the circle, and then projecting it into a 2D plane in the direction of \(N\), as shown in Figure 3; the transformation formula is expressed as Equation (4), where \(R=[a,b,N]\), \(p\) is the 3D coordinate point; \(\overset{\wedge}{p}\) is the 2D coordinate point, and here is the start point or end point, \(o\) is the centre of the circular arc. \[\overset{\wedge}{p}=R_{p}-R_{o}\] (4)
2. In order to remove the \(z\)-axis of the local coordinate system, the start and end points of the two-dimensional plane can be obtained and calculate the sine \(v_{1}\) and cosine \(v_{2}\) of the starting point \(S\) and the ending point \(E\), respectively.
3. The equation obtains the results of the final start point and end point (5). Finally, the direction of the edge curve in the STEP file is used to determine the result (if the direction is \(T\), select \(\theta_{1}\) in Figure 3, otherwise, select \(\theta_{2}\) in Figure 3). The discrete points of a circle can be determined according to the equation of a circle. \[\theta=\left\{\begin{aligned} \arccos(v_{1}),v_{1}>0,v_{2}\geq 0\\ \arccos(v_{1}),v_{1}\leq 0,v_{2}\geq 0\\ \arccos(v_{1})+2[\pi-\arccos(v_{1})],v_{1}<0,v_{2}<0\\ \arcsin(v_{2}),v_{1}\geq 0,v_{2}<0\end{aligned}\right.\] (5)  
According to the parse of boundary, each functional surface is finally divided, as shown in Figure 4.