## 3 Approximate Inverse Kinematics Solution for Imposed End-Effector State
### Calculation of Arc Segments' Endpoints and Orientations
\begin{array}{ccc}1-2s\Big{(}q_{jn}^{2}+q_{kn}^{2}\Big{)} &2s\big{(}q_{in}q_{jn}-q_{kn}q_{rn}\big{)}&2s\big{(}q_{in}q_{kn}+q_{jn}q_{rn} \big{)}\\ 2s\big{(}q_{in}q_{jn}+q_{kn}q_{rn}\big{)}&1-2s\big{(}q_{in}^{2}+q_{kn}^{2}\big{)} &2s\big{(}q_{jn}q_{kn}-q_{jn}q_{rn}\big{)}\\ 2s\big{(}q_{in}q_{kn}-q_{jn}q_{rn}\big{)}&2s\big{(}q_{jn}q_{kn}+q_{in}q_{rn} \big{)}&1-2s\Big{(}q_{in}^{2}+q_{jn}^{2}\Big{)}\end{array} \right], \tag{41}\]  
where the vector's scalar/real part is \(s\), that is \(s=||q||^{-2}\). The quaternion will only rotate the unit vector; therefore, \(s=1\). For clockwise rotation around the same axis by an angle \(\theta_{n}\), the quaternion rotation matrix is as follows:  
\[\mathbf{R}_{\text{alt}n}=\left[ \begin{array}{ccc}1-2s\Big{(}q_{jn}^{2}+q_{ kn}^{2}\Big{)}&2s\big{(}q_{in}q_{jn}+q_{kn}q_{rn}\big{)}&2s\big{(}q_{in}q_{kn}-q_{jn}q_{ rn}\big{)}\\ 2s\big{(}q_{in}q_{jn}-q_{kn}q_{rn}\big{)}&1-2s\big{(}q_{in}^{2}+q_{kn}^{2}\big{)} &2s\big{(}q_{jn}q_{kn}+q_{in}q_{rn}\big{)}\\ 2s\big{(}q_{in}q_{kn}+q_{jn}q_{rn}\big{)}&2s\big{(}q_{jn}q_{kn}-q_{in}q_{rn} \big{)}&1-2s\Big{(}q_{in}^{2}+q_{jn}^{2}\Big{)}\end{array} \right], \tag{42}\]  
The quaternion formula for vector rotation is  
\[\mathbf{v}_{\text{r2}}=q\mathbf{v}_{\text{r1}}q^{\prime}=\mathbf{R}_{n} \mathbf{v}_{\text{r1}}, \tag{43}\]  
where the output vector is \(\mathbf{v}_{\text{r2}}\) and the input vector is \(\mathbf{v}_{\text{r1}}\). If \(\mathbf{v}_{\text{r1}}=(0,0,1)\) then the first segment's orientation vector is  
\[\overset{\wedge}{\mathbf{s}}_{\text{orien1}}=\mathbf{R}_{1}p_{\text{r1}}. \tag{44}\]  
The sum of vector \(\overset{\wedge}{\mathbf{s}}_{\text{orien1}}\) coordinates and point \(P_{\text{1}}\) coordinates is equal to \(S_{\text{orien1}}\). The vector \(\mathbf{s}_{\text{orienN1}}\) represents the first segment orientation vector (Figure 10). \(\mathbf{s}_{\text{orienN1}}\) continues from point \(P_{\text{1}}\) to point \(S_{\text{orienN1}}\), while the vector \(\mathbf{s}_{\text{orienN1}}\) magnitude (Figure 10) is scaled up for illustration purposes. Figure 9: First segment vector \(\mathbf{c}_{\text{1}}\) rotated around \(z\)-axis \(90^{\circ}\) counter-clockwise. To calculate the second segment endpoint's \(P_{2}\) coordinates and orientation vector's \(\mathbf{s}_{\text{orien2}}\) coordinates, the first segment calculations from Equation (22) to Equation (44) are still valid. However, the second segment vector \(\mathbf{p}_{\text{ec12}}\) (from point \(\hat{P}_{\text{ec1}}\) to point \(\hat{P}_{\text{ec2}}\), Figure 5c), from the second segment coordinate system, needs to be transformed into a first segment coordinate system. Therefore, vector \(\mathbf{p}_{\text{ec1}}\) reduces vector \(\mathbf{p}_{\text{ec2}}\) to get \(\mathbf{p}_{\text{sec12}}\), which starts from point \(\mathcal{O}=(0,0,0)\):  
\[\mathbf{p}_{\text{sec12}}=\mathbf{p}_{\text{ec2}}-\mathbf{p}_{\text{ec1}}=( \hat{x}_{\text{ec2}}-\hat{x}_{\text{ec1}},\hat{y}_{\text{ec2}}-\hat{y}_{\text{ ec1}},\hat{z}_{\text{ec2}}-\hat{z}_{\text{ec1}}). \tag{45}\]  
Vector \(\mathbf{p}_{\text{sec12}}\) needs to be rotated clockwise with the first segment quaternion rotation matrix \(\mathbf{R}_{\text{alt1}}\) in Equation (42) and using the quaternion rotation formula in Equation (43):  
\[\mathbf{p}_{\text{ec2}}^{\text{T}}=R_{\text{alt1}}\ \mathbf{p}_{\text{sec12}}. \tag{46}\]  
Vector \(\mathbf{p}_{\text{ec2}}^{\text{T}}\) is a result of the translation to the first segment coordinate system. Figure 11 depicts the \(\mathbf{p}_{\text{ec2}}^{\text{T}}\) vector. Now the second segment chord length \(d_{2}\) allows for scaling vector \(\mathbf{p}_{\text{ec2}}^{\text{T}}\):  
\[\mathbf{p}_{\text{Nec2}}^{\text{T}}=\frac{d_{2}\mathbf{p}_{\text{ec2}}^{\text {T}}}{||\mathbf{p}_{\text{ec2}}^{\text{T}}||}. \tag{47}\]  
Figure 11: Second segment vector \(\mathbf{p}_{\text{ec2}}^{\text{T}}\) calculation representation. Figure 10: First segment with segment endpoint \(P_{1}\) and with segment’s orientation vector \(\mathbf{s}_{\text{orienN1}}\).