## 2 Methods
### PCA-Based Point-Cloud Data Coordinate System Transformation
To reduce the errors introduced by manually selecting the tunnel axis direction, this study uses PCA to calculate the eigenvector of the direction with the maximum variance of the tunnel point cloud (the first principal component direction) to represent the tunnel point cloud's axis direction. Based on this, the tunnel point cloud is rotated, as shown in Figure 4.  
Figure 3: PCA principle diagram. For the original tunnel point-cloud dataset \(X=\{x_{i}\}_{i=1}^{N}\), where each point in the dataset has coordinates \((x_{i},y_{i},z_{i})\), in order to eliminate the effect of the data's position (i.e., the offset) in the coordinate space on the data's feature vector (i.e., the principal component direction), the mean of the point-cloud data must be calculated according to Equation (1), and then all points in the point-cloud dataset are centered by subtracting the mean, as shown in Equation (2). \[\overline{x}=\frac{1}{N}\sum_{i=1}^{N}x_{i} \tag{1}\]  
\[X_{centered}=\{x_{i}-\overline{x}\}_{i=1}^{N} \tag{2}\]  
The original tunnel point-cloud data are centered by subtracting the mean, resulting in the centered tunnel point-cloud dataset \(X_{centered}\). The covariance matrix \(C\) of \(X_{centered}\) is then calculated according to Equation (3). The covariance matrix \(C\) undergoes eigenvalue decomposition, as shown in Equation (4). The principal component corresponds to the largest eigenvalue \(\lambda_{1}\), and the eigenvector \(v_{1}\) associated with \(\lambda_{1}\) represents the axis direction of the tunnel point-cloud data. \[C=\frac{1}{N}\sum_{i=1}^{N}(x_{i}-\overline{x})(x_{i}-\overline{x})^{T} \tag{3}\]  
\[Cv_{i}=\lambda_{i}v_{i} \tag{4}\]  
In the equation, \(\lambda_{i}\) represents the \(i\)-th eigenvalue of the covariance matrix, and \(v_{i}\) is the eigenvector corresponding to \(\lambda_{i}\). The eigenvalues are solved in descending order, such that \(\lambda_{1}>\lambda_{2}>\lambda_{3}\). To align the obtained principal axis direction of the point cloud with the Z-axis direction, the rotation axis r and the rotation angle \(\theta\) need to be calculated. Based on these, the rotation matrix R is computed. The rotation vector r is calculated as shown in Equation (5), and the normalized rotation vector \(r_{norm}\) is calculated as shown in Equation (6), which represents the direction of rotation. The x, y, and z axes represent the corresponding rotation vectors \(r_{x}\), \(r_{y}\), \(r_{z}\). The rotation angle \(\theta\) can be computed using the dot product between the principal axis and the Z-axis, as shown in Equation (7). Figure 1:0  
Figure 1:1 Point-cloud data rotation along axis direction schematic (unit: meters). Figure 1:2  
Figure 1:3  
In the equation, \(\|v_{1}\|\) and \(\|z\|\) represent the magnitudes of the unit vectors along the principal axis and the z-axis, respectively. In three-dimensional space, the rotation matrix can be generated using axis-angle representation. For any point \((x_{i},y_{i},z_{i})\) in space, the coordinates of the rotated point can be directly obtained by multiplying it with the rotation matrix \(R\). Given a rotation vector \(r_{norm}\) and a rotation angle \(\theta\), the rotation matrix \(R\) can be generated using Rodrigues' equation, as shown in Equation (8). The skew-symmetric matrix is defined in Equation (9). Figure 1:4  
\[K= \begin{bmatrix}0&-r_{z}&r_{y}\\ r_{z}&0&-r_{x}\\ -r_{y}&r_{x}&0\end{bmatrix}  \tag{9}\]  
The original point cloud is rotated along the tunnel axis, and the entire-tunnel point cloud is rotated to align with the z-axis direction, as shown in Figure 5.