## 2 Tunnel Model Construction
### LHD Machine Simulation Modeling  
The body of the LHD machine model is composed of front and rear parts, and the middle is connected by a hinge device. The bucket is divided into six \(Z\)-type reverse bars and eight forward, bars according to the structural characteristics. Based on the model of the LHD machine made in Qingdao Zhonghong, this paper selected six \(Z\)-type reverse bars as the structural characteristics to build the model. The main components of the LHD machine are the front body, the rear body, and the bucket. The bucket is connected to the front body by the tilting oil cylinder and piston, the lifting oil cylinder, piston, the swing arm, rocker arm, and connecting rod. To achieve steering of the LHD machine, two symmetrical steering pistons need to be set at the connection between the front body and the rear body. UE4 has two methods to realize object displacement and rotation: physical simulation, and coordinate transformation. Using the physical simulation method requires turning on the simulated physics of the static mesh in advance and add constraints in different directions, it requires a high accuracy and no overlap between the various components, otherwise unpredictable errors will occur. Pure physical simulation is usually used when the model structure is not complex or there are few connections between models. For a complex body model, such as the LHD machine model, the use of pure physical simulation will not only increase the consumption of computer resources but also lead to various abnormalities. For the movement simulation of the LHD machine, only the acceleration and deceleration control needs to be realized, and the overall coordinate transformation of the LHD machine can be realized through a physical formula, which can accurately simulate the walking of the LHD machine. Note that UE4 adopts a left-hand coordinate system instead of a right-hand coordinate system, as shown in Figure 2.  
Figure 1: Tunnel point cloud data acquisition and model optimization, color represents the \(Z\) value. (**a**) Original point cloud data of real tunnel; (**b**) tunnel model after import UE4; (**c**) original state inside of the tunnel; (**d**) final state inside of the tunnel. The movement of the LHD machine can be regarded as the movement of object coordinates in three-dimensional space, and the motion simulation of object coordinates is based on the translation and rotation transformation of the coordinate system. The translation transformation process can be simply represented by Equation (1):  
\[\left\{ \begin{array}{l}x_{1}=x+t_{x}\\ y_{2}=y+t_{y}\\ z_{3}=z+t_{z}\end{array} \right. \tag{1}\]  
The rotation matrix can be derived from the following matrix, which rotates \(\alpha\) degrees around the \(Z\)-axis \(R_{Z}\) is  
\[R_{Z}=\left[ \begin{array}{ccc}\cos\alpha&-\sin\alpha&0\\ \sin\alpha&\cos\alpha&0\\ 0&0&1\end{array} \right] \tag{2}\]  
Similarly, rotates \(\gamma\) degrees around the \(X\)-axis \(R_{X}\) and rotates \(\beta\) degrees around the \(Y\)-axis \(R_{Y}\) are  
\[R_{X}=\left[ \begin{array}{ccc}1&0&0\\ 0&\cos\gamma&-\sin\gamma\\ 0&\sin\gamma&\cos\gamma\end{array} \right] \tag{3}\]  
\[R_{Y}=\left[ \begin{array}{ccc}\cos\beta&0&\sin\beta\\ 0&1&0\\ -\sin\beta&0&\cos\beta\end{array} \right] \tag{4}\]  
Therefore, the final rotation matrix of the coordinate system after three rotations of the object is:  
\[ \begin{array}{l}R_{ZYX}=R_{Z}R_{Y}R_{X}\\ =\left[\begin{array}{ccc}\cos\alpha\cos\beta&\cos\alpha\sin\beta\sin\gamma- \sin\alpha\cos\gamma&\cos\alpha\sin\beta\cos\gamma+\sin\alpha\sin\gamma\\ \sin\alpha\cos\beta&\sin\alpha\sin\beta\sin\gamma+\cos\alpha\cos\gamma&\sin \alpha\sin\beta\cos\gamma-\cos\alpha\sin\gamma\\ -\sin\beta&\cos\beta\sin\gamma&\cos\beta\cos\gamma\end{array}\right]\end{array}  \tag{5}\]  
Matrix \(R_{ZYX}\) is the rotation matrix after the object rotates around the \(Z\), \(Y\), and \(X\) axes, in turn. According to the above method, the rotation matrix of the object according to other rotation orders can be solved.