# Trajectory Planning of Shape-Following Laser Cleaning Robot for the Aircraft Radar Radome Coating
## 2 Materials and Methods
### Measurement and Preprocessing of Point Cloud Data for Radar Dome Surfaces
#### 2.1.3 Point Cloud Data Alignment  
After preprocessing, the point cloud shape of the aligned radome became evident. However, it was necessary to align the coordinates of measuring and cleaning systems before the segmentation of the radome point cloud. To solve this issue, this study introduced the principal component analysis (PCA) algorithm for aligning the point cloud data. Specifically, the research focuses on studying the orientation determination of the principal axis vectors for point cloud alignment. A PCA-based point cloud alignment algorithm was proposed, incorporating an additional criterion for determining the main direction. The algorithm's specific steps for aligning the point cloud data are outlined as follows. Firstly, decentralize the point cloud dataset \(P=\{P_{1},P_{2},P_{3},\cdots,P_{n}\}\):  
\[\overline{Q}_{P}=\frac{\sum_{i=1}^{n}P_{i}}{n} \tag{5}\]  
The covariance matrix of dataset P can be calculated as:  
\[C_{P}=\frac{1}{N}{\sum_{i=1}^{n}\left(P_{i}-\overline{Q}_{P}\right)\left(P_{i }-\overline{Q}_{P}\right)^{T}} \tag{6}\]  
Figure 4: Radome point cloud shape after preprocessing. Through eigenvalue decomposition calculation, the covariance matrix Eigenvalues and eigenvectors of \(C_{P}\) can be expressed as:  
\[C_{P}=U_{P}D_{P}U_{P}^{T} \tag{7}\]  
where \(U_{P}\) is a 3 \(\times\) 3 matrix composed of the eigenvectors of the covariance matrix \(C_{P}\), used to identify the main directions of the point cloud data, and \(D_{P}\) is a 3 \(\times\) 3 diagonal matrix whose diagonal elements are the eigenvalues of the covariance matrix, indicating the variance of data in each direction. Then a new O-XYZ right-hand coordinate system needed to be established. By taking the centroid coordinates \(\overline{Q}_{P}\) as the origin of the new coordinate system, the first principal component of the eigenvector corresponding to the maximum eigenvalue was chosen as the \(X\)-axis of the new coordinate system. The second principal component of the eigenvector corresponding to the second largest eigenvalue was chosen as the \(Y\)-axis of the new coordinate system. Thereby, the O-XY plane was formed. By performing a cross-product operation on the \(X\)-axis and \(Y\)-axis, the new \(Z\)-axis coordinate was obtained and the new O-XYZ coordinate system was established. By utilizing the newly constructed O-XYZ coordinate system, the coordinate transformation matrix \((R_{P},T_{P})\) dataset could be computed to obtain the axis-aligned set \(P^{\prime}\). \[\left\{ \begin{array}{l}R_{P}=U_{P}^{T}\\ T_{P}=-R_{P}*\overline{Q}_{P}\end{array} \right. \tag{8}\]  
\[P^{\prime}=P*R_{P}+T_{P} \tag{9}\]  
where \(R_{P}\) is the rotation matrix and \(T_{P}\) is the translation vector. There may exist a problem with the \(Z\)-axis orientation, resulting in a scenario where the aligned point cloud exhibits an inverted orientation as depicted in Figure 5b. Specifically, when the \(Z\)-component values of the point cloud data are negative, it indicates a reversal in the \(Z\)-axis direction. Consequently, after the initial alignment of the point cloud coordinate system, it was necessary to perform \(Z\)-axis direction determination and correction. We needed to search for the maximum point \(P_{k1}^{\prime}\) and the minimum point \(P_{k2}^{\prime}\) in the point cloud set \(P^{\prime}\). Extract the corresponding \(Z\)-axis component values \(z_{k1}\) and \(z_{k2}\), respectively. Take the absolute values of \(z_{k1}\) and \(z_{k2}\) and calculate their difference as shown in Equation (10). From the perspective of the point cloud data, this step involves comparing the maximum and minimum points of the point cloud set to determine if the \(Z\)-axis is reversed.