## 2 Directed Angular Restitution (DAR)  
In this section, the Directed Angular Restitution (DAR) method is developed. This proposed method allows for the alignment of links connected by rotational joints, facilitating the calculation of inverse kinematics in trajectory planning. It establishes continuity in the direction of rotation using spin functions, which are crucial for ensuring precise movement in robotic applications. The basic concept in the DAR method starts with the calculation of the angle between vectors, as illustrated in Figure 1 (in the \(xz\) plane). To determine \(\Delta q\) between the vectors \(r_{a,b}\) and \(r_{a,c}\), the following three trigonometric expressions are used, incorporating the elimination and selection vectors to ensure correctness in \(\mathbb{R}^{3}\):  
\[\Delta q=\cos^{-1}\!\left(\frac{\left(\mathbf{E_{y}}\otimes r_{a,b}\right) \otimes\left(\mathbf{E_{y}}\otimes r_{a,c}\right)}{\left\|\mathbf{E_{y}} \otimes r_{a,b}\right\|\left\|\mathbf{E_{y}}\otimes r_{a,c}\right\|}\right) \tag{1}\]  
\[\Delta q=\sin^{-1}\!\left(\frac{\mathbf{S_{y}}\cdot\left(\mathbf{E_{y}}\otimes r _{a,b}\right)\times\mathbf{E_{y}}\otimes r_{a,c}}{\left\|\mathbf{E_{y}} \otimes r_{a,b}\right\|\left\|\mathbf{E_{y}}\otimes r_{a,c}\right\|}\right) \tag{2}\]  
\[\Delta q=\tan^{-1}\!\left(\frac{\mathbf{S_{y}}\cdot\left(\mathbf{E_{y}}\otimes r _{a,b}\times\mathbf{E_{y}}\otimes r_{a,c}\right)}{\left(\mathbf{E_{y}}\otimes r _{a,b}\right)\cdot\left(\mathbf{E_{y}}\otimes r_{a,c}\right)}\right) \tag{3}\]  
where \(\mathbf{E_{y}}= \begin{bmatrix}1&0&1\end{bmatrix} ^{T}\) is the elimination vector, \(\mathbf{S_{y}}= \begin{bmatrix}0&1&0\end{bmatrix} ^{T}\) is the selection vector for the \(xz\) plane and \(\left(\cdot\right)\otimes\left(\cdot\right)\) is the Hadamar product. The elimination and selection vectors for the other planes are summarized in Table 1. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Plane** & **Elimination Vector E** & **Selection Vector S** \\ \hline \(yz\) & \(\mathbf{E_{x}}=\begin{bmatrix}0&1&1\end{bmatrix}^{T}\) & \(\mathbf{S_{x}}=\begin{bmatrix}1&0&0\end{bmatrix}^{T}\) \\ \(xz\) & \(\mathbf{E_{y}}=\begin{bmatrix}1&0&1\end{bmatrix}^{T}\) & \(\mathbf{S_{y}}=\begin{bmatrix}0&1&0\end{bmatrix}^{T}\) \\ \(xy\) & \(\mathbf{E_{z}}=\begin{bmatrix}1&1&0\end{bmatrix}^{T}\) & \(\mathbf{S_{z}}=\begin{bmatrix}0&0&1\end{bmatrix}^{T}\) \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Elimination and selection vectors for different planes in \(\mathbb{R}^{3}\). Figure 1: Calculation of the angle between vectors \(r_{a,b}\) and \(r_{a,c}\) in the \(xz\) plane. To ensure the correct direction of rotation, spin functions are introduced. These functions use the components of the vectors \(r_{a,b}\) and \(r_{a,c}\) to determine the direction:  
\[d_{x}=1-\frac{2}{\exp(\infty\cdot(\epsilon+y_{a,b}\cdot z_{a,c}-y_{a,c}\cdot z _{a,b}))+1} \tag{4}\]  
\[d_{y}=1-\frac{2}{\exp(\infty\cdot(\epsilon-x_{a,b}\cdot z_{a,c}+x_{a,c}\cdot z _{a,b}))+1} \tag{5}\]  
\[d_{z}=1-\frac{2}{\exp(\infty\cdot(\epsilon+x_{a,b}\cdot y_{a,c}-x_{a,c}\cdot y _{a,b}))+1} \tag{6}\]  
where \(r_{a,b}=\left[x_{a,b}\;\;y_{a,b}\;\;z_{a,b}\right]^{T}\), \(r_{a,c}=\left[x_{a,c}\;\;y_{a,c}\;\;z_{a,c}\right]^{T}\) and \(\epsilon\) is the epsilon machine \"eps\" [20]. These spin functions are saturated sigmoid functions of the type:  
\[sf(x)=1-\frac{2}{1+e^{(x-\epsilon)\cdot\infty}}= \begin{cases}1;\;\;\;\;\;x>0, \\ -1;\;\;\;x<0,\\ 1;\;\;\;\;\;x=0.\end{cases}  \tag{7}\]  
The function \(sf(x)\) is a saturated sigmoid function, which behaves similarly to a sign function but excludes zero from its results. This ensures that the direction of rotation is unambiguous. The function \(sf(x)\) ensures the continuity of the rotational direction, providing a clear indication of whether the rotation should be clockwise or counterclockwise.