## 2 Surface Shape Measurement Principle
### Detection Principle
#### 2.2.2 Overall Design of the Detection System  
As a long rotary part, to determine its spatial position, we should determine the relative position of the axis in space and combine it with its prime line position. As shown in Figure 4, six grating probes are unevenly distributed on the lower half circle of a concentric circle in a vertical plane. The measuring plane, where the grating probes are located, is the \(Y\)-\(O\)-\(Z\) plane. The intersection point of the straight extension line, where the grating probes are located, is the space origin. And the cartesian left hand rule establishes the coordinate system \(O\)-\(X\)-\(Y\)-\(Z\). One end of the shaft usually features a cylindrical surface, assuming that the cylindrical surface intersects the \(Y\)-\(O\)-\(Z\) plane, as shown in the picture. According to the principle of spatial geometry, the intersection of the cylinder and plane is an ellipse, and the intersection of the axis and plane \(x=0\) is an ellipse. The essence of an ellipse is a conic. Through the probe, the multipoint coordinates on the \(Y\)-\(O\)-\(Z\) plane of the ellipse are obtained, and the ellipse is in the plane of \(x=0\) so as to obtain the spatial coordinate (\(0,y,z\)). The general equation of an ellipse is  
\[F(y,z)=ay^{2}+byz+cz^{2}+dy+ez+f=0 \tag{5}\]  
Among them \(a\), \(b\), \(c\), \(d\), \(e\), and \(f\) are parameters, and there is a constraint: \(b^{2}-4 ac>0\). Define the vector \(\mathbf{A_{x}}=\left[a,b,c,d,e,f\right]^{T}\), \(\mathbf{X}=\left[y^{2},yz,z^{2},y,z,1\right]\). The problem of a curve fitting to a group of known points is expressed by the sum of squares of the minimum distance from point to the curve as  
\[\min_{A}\sum_{i=1}^{n}\mathbf{F}(y_{i},z_{i})^{2}=\min_{A}\sum_{i=1}^{n}\left(\bm {X}_{i}\cdot\mathbf{A_{x}}\right)^{2} \tag{6}\]  
It is known that vector \(\mathbf{A_{x}}\) multiplied by any coefficient is still the same equation; thus, the constraint condition can be transformed into \(b^{2}-4 ac=1\). The fitting problem in the ellipse data of the detection section can be expressed as  
\[\min_{A}\lVert\mathbf{Da}\rVert^{2}\ \ \text{Constraints}:\ \mathbf{A_{x}}^{T}\mathbf{ CA_{x}}=1 \tag{7}\]  
Figure 4: Schematic diagram of measuring system. (**a**) The overall view of the system is used to show the overall layout of the device; (**b**) The layout view of the grating probe detection device shows the specific space layout of the probe. Among them,  
\[\mathbf{D}= \begin{pmatrix}{y_{1}}^{2}&{y_{1}}{z_{1}}&{z_{1}}^{2}&{y_{1}}&{z_{1}}&1\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ {y_{2}}^{2}&{y_{i}}{z_{i}}&{z_{i}}^{2}&{y_{i}}&{z_{i}}&1\\ \vdots&\vdots&\vdots&\vdots&\vdots&\vdots\\ {y_{n}}^{2}&{y_{n}}{z_{n}}&{z_{n}}^{2}&{y_{n}}&{z_{n}}&1\end{pmatrix} ,\ \mathbf{C}= \begin{pmatrix}0&0&2&0&0&0\\ 0&-1&0&0&0&0\\ 2&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\\ 0&0&0&0&0&0\end{pmatrix} \]  
By using Lagrange multiplier and a series of simplified formulas, the elliptic curve equation can be solved through direct solution. The center \(C_{t}(x_{0},y_{0},z_{0})\) of the ellipse can be obtained by using the ellipse equation with a known cross-section. \[\left\{ \begin{array}{l}x_{0}=0\\ y_{0}=\frac{be-2\varepsilon d}{4\varepsilon c-b^{2}}\\ z_{0}=\frac{bd-2\varepsilon d}{4\varepsilon c-b^{2}}\end{array} \right. \tag{8}\]  
Determining the position of the spatial axis needs a point on the axis and the direction vector of the axis. It is known that the center of the ellipse is a point on the axis, so only the value of the direction vector is required next. An ellipse is the intersection of a cylindrical surface and a plane. All points on the ellipse are on the cylindrical surface, and the distances from point \((x_{i},y_{i},z_{i})\) to the axis on the ellipse are the same.