## 3 Inverse and Forward Kinematics Problems
### Inverse Kinematics  
Calculating the required rotations of rotary actuators and lower levers for a given position and orientation of the platform requires solving the inverse kinematics. The most intuitive way of solving this type of problem is often referred to as a geometric method. Using translation vector \(\mathbf{T}\) and rotation matrix \(\mathbf{R}\), it is possible to obtain a position vector of a point \(P_{i}\) in reference to the global reference frame. The necessary length of the leg (distance between points \(B_{i}\) and \(P_{i}\)) can be computed by the Euclidean norm of the vector \(\mathbf{L}_{i}\) shown in Figure 4 as \(l_{i}=\left\|\mathbf{L}_{i}\right\|_{2}\). After calculating the vector \(\mathbf{L}_{i}\), the next step is to find the angle of rotation \(\alpha_{i}\) for the rotary actuator. This angle defines rotation around the axis of the actuator, while this axis is defined by a unit vector \(\mathbf{i}_{m,i}\). The purpose of finding the angle \(\alpha_{i}\) is to define the position of the point \(A_{i}\), which provides the correct position of upper and lower levers for the defined leg length. Angle \(\alpha_{i}\) is measured from the initial vector \(\mathbf{B}_{i}\mathbf{A}_{i}\), which lies in the horizontal plane. The actuator's axis of rotation and the circle representing all possible positions of the point \(A_{i}\) are also shown in Figure 4. For the introduced reference frames, the following relation determines the vector of the \(i\)-th leg. \[\mathbf{L}_{i}=\mathbf{T}+\mathbf{R}\,\mathbf{p}_{i}-\mathbf{b}_{i} \tag{14}\]  
Home position offset can be implemented in the already defined translation vector \(\mathbf{T}\) as follows:  
\[\mathbf{T}= \begin{bmatrix}x&y&z_{0}+z\end{bmatrix} ^{T} \tag{15}\]  
The home position is the selected position in which lower levers are in plane with the base. This position of the platform is defined as:  
\[z_{0}=\sqrt{s^{2}-(x_{P_{1}}-x_{A_{1}})^{2}-(y_{P_{1}}-y_{A_{1}})^{2}}+z_{A_{ 1}} \tag{16}\]  
Using now known vectors \(\mathbf{p}_{i}\) and \(\mathbf{b}_{i}\), and known lengths \(a\), \(s\), and \(L_{i}\), angle \(\alpha_{i}\) can be obtained from coordinates of vector \(\mathbf{a}_{i}\). After solving a system of equations and using trigonometric identities, the following equation is obtained:  
\[\mathbf{\alpha}=\sin^{-1}\biggl{(}\frac{\mathbf{D}}{\sqrt{\mathbf{E}^{2}+\mathbf{F}^{2}}} \biggr{)}-\text{atan2}(\mathbf{F},\mathbf{E}) \tag{17}\]  
The function atan2 from the previous equation is defined as:\[\text{atan2}(F_{i},E_{i})= \begin{cases}\tan^{-1}\biggl{(}\dfrac{F_{i}}{E_{i}} \biggr{)},&E_{i}>0,\\ \tan^{-1}\biggl{(}\dfrac{F_{i}}{E_{i}}\biggr{)}+\pi,&E_{i}<0\wedge F_{i}\geq 0,\\ \tan^{-1}\biggl{(}\dfrac{F_{i}}{E_{i}}\biggr{)}-\pi,&E_{i}<0\wedge F_{i}<0,\\ +\dfrac{\pi}{2},&E_{i}=0\wedge F_{i}>0,\\ -\dfrac{\pi}{2},&E_{i}=0\wedge F_{i}<0,\\ \text{NaN},&E_{i}=0\wedge F_{i}=0.\end{cases}  \tag{18}\]  
In Equation (17), variables \(\mathbf{D}\), \(\mathbf{E}\), and \(\mathbf{F}\) are:  
\[\mathbf{D}=I^{2}+a^{2}-s^{2}-2(\mathbf{R}\mathbf{m}\mathbf{1}_{\mathbf{B}\mathbf{A}}+\mathbf{B}\mathbf{A}_{0}) \,\mathbf{B}\mathbf{P} \tag{19}\]  
\[\mathbf{E}=2\mathbf{R}\mathbf{m}\mathbf{2}_{\mathbf{B}\mathbf{A}}\cdot\mathbf{B}\mathbf{P} \tag{20}\]  
\[\mathbf{F}=-2\mathbf{R}\mathbf{m}\mathbf{1}_{\mathbf{B}\mathbf{A}}\cdot\mathbf{B}\mathbf{P} \tag{21}\]  
With the obtained Equation (17), the inverse kinematics problem is solved. This equation is the explicit solution to the inverse kinematics problem. If there is a real solution to this equation for all angles \(\alpha_{i}\), then the desired position and orientation of the platform are achievable if there are no other physical constraints. In the process of designing a mechanism like this for practical usage as a flight simulator, the physical constraints of the kinematic chains, such as lever interference and limitations of joints, must be considered [9]. Whenever some mechanism has spherical or universal joints, their angular limits should be considered [29].