# Design of Optical Free-Form Surface Milling Machine Based on Mechanical Shunt and Dynamic Analysis
## 4 Establishment and Simulation of Virtual Prototype for Optical Free-Form Surface Milling Machine  
### ADAMS Dynamics Equation  
In ADAMS, the Cartesian coordinates of the mass center of the rigid body \(B\) and the Euler angles reflecting the orientation of the rigid body are used as generalized coordinates, namely, \(q=[x,y,z,\psi,\theta,\varphi]^{T}\), let \(R=[x,y,z]^{T}\), \(\gamma=[\psi,\theta,\phi]^{T}\), \(q=\left[R^{T},\gamma^{T}\right]^{T}\). The coordinate transformation matrix between the component centroid reference coordinate system and the geodetic coordinate system is:  
\[A^{gi}=\left[ \begin{array}{ccc}\cos\psi\cos\phi-\sin\psi\cos\theta\sin\phi&- \cos\psi\sin\phi-\sin\psi\cos\theta\cos\phi&\sin\psi\sin\theta\\ \sin\psi\cos\phi+\cos\psi\cos\theta\sin\phi&-\sin\psi\sin\phi+\cos\psi\cos \theta\cos\phi&-\cos\psi\sin\theta\\ \sin\theta\sin\phi&\sin\theta\cos\phi&\cos\theta\end{array} \right] \tag{1}\]  
Define a Euler rotation axis coordinate system, the three unit-vectors of the coordinate system are the axes of the above three Euler rotations, so the three axes are not perpendicular to each other. The coordinate transformation matrix from this coordinate system to the component centroid coordinate system is:  
\[B=\left[ \begin{array}{ccc}\sin\theta\cos\phi&0&\cos\theta\\ \sin\theta\cos\phi&0&-\sin\theta\\ \cos\theta&1&0\end{array} \right] \tag{2}\]  
The angular velocity expression of the component is:  
\[\omega=B_{\gamma}^{\bullet} \tag{3}\]  
The variable \(\omega_{e}\) introduced in ADAMS is the component of the angular velocity in the Euler axis of rotation coordinate system:  
\[\omega_{e}=\gamma_{\gamma}^{\bullet} \tag{4}\]  
Considering the constraint equation, ADAMS uses the energy form of the first type Lagrangian equation with Lagrangian multipliers, to obtain the following equation:  
\[\frac{d}{dt}\left(\frac{\partial T}{\partial\dot{q}_{j}^{\bullet}}\right)- \frac{\partial T}{\partial q_{j}}=Q_{j}+\sum_{i=1}^{n}\lambda_{i}\frac{ \partial\phi}{\partial q_{j}} \tag{5}\]  
\(T\) is the kinetic energy expressed in the generalized coordinate system, \(q_{j}\) is the generalized coordinate, and \(Q_{j}\) is the generalized force in the generalized coordinate direction. The last term involves the constraint equation and the Lagrange multiplier, which expresses the constraint reaction force in the generalized coordinate direction. ADAMS further introduces a generalized momentum:  
\[P_{j}=\frac{\partial T}{\partial\dot{q}_{j}} \tag{6}\]  
A simplified expression of the constraint reaction force is:  
\[C_{j}=\sum_{i=1}^{n}\lambda_{i}\frac{\partial\phi}{\partial q_{j}} \tag{7}\]  
So, Equation (6) is simplified to:  
\[\dot{P}_{j}-\frac{\partial T}{\partial q_{j}}=Q_{j}-C_{j} \tag{8}\]We express Equation (8) as the direction of movement and the direction of rotation, respectively:  
\[\overset{\bullet}{P}_{R}-\frac{\partial T}{\partial q_{R}}=Q_{R}-C_{R} \tag{9}\]  
\[\overset{\bullet}{P}_{\gamma}-\frac{\partial T}{\partial q_{\gamma}}=Q_{\gamma} -C_{\gamma} \tag{10}\]  
In Equation (9), \(\overset{\bullet}{P}_{R}=\frac{d}{dt}\left(\frac{\partial T}{\partial q_{R}} \right)=\frac{d}{dt}\left(\overset{\bullet}{R}\overset{\bullet}{R}\right)=M \overset{\bullet}{V}\), \(\frac{\partial T}{\partial q_{R}}=0\). Equation (9) is simplified to: \(M\overset{\bullet}{V}=Q_{R}-C_{R}\)  
\(B\) contains the Euler angles. In order to simplify the derivation, ADAMS does not further derive \(\overset{\bullet}{P}_{\gamma}\), but solves it as a variable. In this way, each component in ADAMS has the following variables and equations. Among them, \(M\) is the mass matrix of the component, and \(J\) is the inertia matrix of the component in the center of mass coordinate system. Variable:  
\[ \begin{array}{l}V=\left[V_{x},V_{y},V_{z}\right]^{T}\\ R=\left[x,y,z\right]^{T}\\ P_{\gamma}=\left[P_{\phi},P_{\theta},P_{\phi}\right]^{T}\\ \omega_{e}=\left[\omega_{\phi},\omega_{\phi},\omega_{\phi}\right]^{T}\\ \gamma=\left[\psi,\theta,\phi\right]^{T}\end{array}  \tag{11}\]  
Equation:  
\[