# Automated Tunnel Point Cloud Segmentation and Extraction Method
## 2 Materials and Methods
### Application of the GuSAC Algorithm
#### 2.1.2 Segmented Fitting of the Designed Axis  
In subway tunnel design, directly fitting the entire designed tunnel axis can result in the loss of many critical features. This is particularly true in special cases where the alignment cannot be accurately represented by a single function. Therefore, dividing the tunnel axis into curved sections and straight sections and expressing them using piecewise functions can more precisely reflect the overall alignment of the tunnel. The specific steps for axis segmentation fitting are as follows:  
1. Direct fitting of the 3D axis is complex. To simplify, a tangent space coordinate system is constructed by calculating the cumulative path length and the tangent direction relative to the positive x-axis of the coordinate system. Specifically: * Cumulative Path Length: Starting from the initial point, the Euclidean distances between each pair of adjacent points are progressively summed to obtain the path length from each point to the starting point. * Tangent Direction Angle: Using a least-squares linear fitting method within a defined neighborhood around each point, the slope k of the fitted line is calculated. The angle formed with the horizontal axis is then used as the y-axis of the tangent space coordinate system. The designed axis obtained in this experiment is illustrated in Figure 1 below. 2. The points in the tangent space coordinate system are processed using a sliding window method to identify turning points. Within the local neighborhood of each point, the tangent direction angle data are smoothed using a mean convolution kernel. In the smoothed data, the trend within the window range is analyzed to determine whether a change in trend occurs. The specific criteria for identifying changes are as follows: * If the angle values within the window gradually increase, the trend is identified as \"increasing.\" * If the angle values gradually decrease, the trend is identified as \"decreasing.\" * If the variation in angle values is smaller than a preset threshold, the trend is considered \"unchanged.\" Points with significant changes in trend are marked as turning points. In this experiment, an effective segmentation of the tunnel axis is achieved by setting the sliding window size to 20 parameters and the threshold to 0.001. The threshold value should be appropriately adjusted for different axis data. The operational results under the above parameters are shown in Figure 2.  
Figure 1: Schema of the designed tunnel axis. 3. Repeat the above steps, performing reverse calculations starting from the tunnel endpoint as the initial point. For the boundary points obtained from the two runs, determine whether adjacent boundary points exist by checking if the difference in cumulative path lengths is smaller than a preset threshold. If adjacent boundary points are identified, their average value is taken as the optimized boundary point position. If no adjacent points are found, the original boundary point is retained to avoid misadjustments of significant boundary points. 4. The turning points are mapped back to the original point cloud space, and the point cloud data are divided into multiple continuous segments. Finally, the segmented point cloud parts are saved as independent files. Then, the least squares curve fitting algorithm is applied to perform cubic curve fitting on each segment of point cloud data. The resulting graph, as shown in Figure 3, gives the parametric equation for the tunnel crown design axis. Figure 3: Tunnel Centerline Segmentation Result. Figure 2: Turning Point Identification in the Tangential Space. \[z(x)= \begin{cases}a_{3,1}x^{3}+a_{2,1}x^{2}+a_{1,1}x+a_{0,1}&x\in[x_{1},x_{2}]\\ a_{3,2}x^{3}+a_{2,2}x^{2}+a_{1,2}x+a_{0,2}&x\in[x_{2},x_{3}]\\ \vdots&\vdots\\ a_{3,m}x^{3}+a_{2,m}x^{2}+a_{1,m}x+a_{0,m}&x\in[x_{m},x_{m+1}]\end{cases}  \tag{1}\] \[y(x)=