# Photogrammetry-Based 3D Textured Point Cloud Models Building and Rock Structure Estimation
## 3 Coordinate Transformation  
It should be noted that in Meshroom, only the relative positions of points are accurate, rather than the physical coordinates; therefore, point cloud models built by Meshroom must be scaled and rotated before conducting measurements. Meshlab is open-source software for processing and editing 3D point cloud models ([[https://www.meshlab.net/#download](https://www.meshlab.net/#download)]([https://www.meshlab.net/#download](https://www.meshlab.net/#download)), accessed on 12 January 2022), and it provides a series of tools for editing, cleaning, healing, inspecting, rendering, texturing, and converting meshes. The postprocessing of coordinate transformation and trace line extraction were finished in Meshlab after the textured 3D point cloud model had been built in Meshroom. The coordinates of at least four feature points on the slope should be measured simultaneously in Meshlab and in the field (denoted as _CF_ and _CT_, respectively) to obtain the transformation matrix. _CF_ can be directly extracted in Meshlab, but _CT_ needs to be measured with a total station in the field. The processes of the transformation can be summarized by Equation (1). \[\mathbf{Trammat}= \begin{bmatrix}\mathbf{R}\cdot S&\mathbf{T}\\ \mathbf{O}&1\end{bmatrix}  \tag{1}\]  
In Equation (1), _Trammat_ is a 4-by-4 matrix, which represents the total transformation of the 2 sets of paired points; \(\mathbf{R}\) is a 3-by-3 matrix representing the rotation transformation; \(S\) is a scalar, which represents the scale factor; \(\mathbf{T}\) is a 3-by-1 matrix, which signifies the translation; \(\mathbf{O}\) is a 1-by-3 zero matrix. The matrixes of \(\mathbf{R}\) and \(\mathbf{T}\), and the scale factor of \(S\) can be solved according to \(\mathbf{CF}\) and \(\mathbf{CT}\), which are the coordinates of two sets of paired points (Equations (2) and (3)). Each set of the points can be represented by a 4-by-3 matrix. The \(N\)th row in the matrixes consists of the coordinates of the \(N\)th point (\(N\) is not greater than 4). \[\mathbf{CF}= \begin{bmatrix}x_{\text{F1}}&y_{\text{F1}}&z_{\text{F1}}\\ x_{\text{F2}}&y_{\text{F2}}&z_{\text{F2}}\\ x_{\text{F3}}&y_{\text{F3}}&z_{\text{F3}}\\ x_{\text{F4}}&y_{\text{F4}}&z_{\text{F4}}\end{bmatrix}  \tag{2}\]  
\[\mathbf{CT}= \begin{bmatrix}x_{\text{T1}}&y_{\text{T1}}&z_{\text{T1}}\\ x_{\text{T2}}&y_{\text{T2}}&z_{\text{T2}}\\ x_{\text{T3}}&y_{\text{T3}}&z_{\text{T3}}\\ x_{\text{T4}}&y_{\text{T4}}&z_{\text{T4}}\end{bmatrix}  \tag{3}\]  
The centroids of _CF_ and _CT_ can be calculated by Equations (4) and (5), respectively. The mean values of each set of coordinates should be translated to the origin of its own coordinate system; this can be done by subtracting from the point coordinates of the centroid. Equations (6) and (7) correspond to this process. \[\mathbf{CF CEN}_{\text{lj}}=\frac{1}{4}\sum_{i=1}^{4}\mathbf{CF}_{ij} \tag{4}\]  
\[\mathbf{CT CEN}_{\text{lj}}=\frac{1}{4}\sum_{i=1}^{4}\mathbf{CT}_{ij} \tag{5}\]  
\[\mathbf{CFC}_{ij}=\mathbf{CT}_{ij}- \begin{bmatrix}\mathbf{CF CEN}\\ \mathbf{CF CEN}\\ \mathbf{CF CEN}\\ \mathbf{CT CEN}\end{bmatrix} _{ij} \tag{6}\]  
\[\mathbf{CTC}_{ij}=\mathbf{CT}_{ij}- \begin{bmatrix}\mathbf{CT CEN}\\ \mathbf{CT CEN}\\ \mathbf{CT CEN}\\ \mathbf{CT CEN}\end{bmatrix} _{ij} \tag{7}\]In Equations (4)-(7), \(j\) ranges from 1 to 3; _CFCEN_ and _CTCEN_ are the mean values of _CF_ and _CT_, respectively; _CFC_ and _CTC_ are the coordinate matrixes of _CF_ and _CT_, respectively, after translation to the origin of their own respective coordinate system. The scale factor can be calculated by Equations (8)-(10). \[S_{\text{F}}=\left(\frac{1}{4}\sum_{i=1}^{4}\sum_{j=1}^{3}\textbf{{CFC}}_{ij}^{ 2}\right)^{0.5} \tag{8}\]  
\[S_{\text{T}}=\left(\frac{1}{4}\sum_{i=1}^{4}\sum_{j=1}^{3}\textbf{{CTC}}_{ij}^ {2}\right)^{0.5} \tag{9}\]  
\[S=\frac{S_{\text{T}}}{S_{\text{F}}} \tag{10}\]  
In Equations (8)-(10), \(S_{\text{F}}\) and \(S_{\text{T}}\) are the size factors of _CF_ and _CT_, respectively.