Rotating base frame thus one of the child frames points to a specific location

78 Views Asked by At

Lately I've been studying with frames and transformation matrices. I have a problem that looks simple yet I couldn't wrap my head around it. Here is my problem with images.

Let's say we have two frames and a point (white sphere in picture). Frame A and Frame B. Frame B is child of Frame A.

Frame A, Frame B and a white sphere as a point.

I want to rotate Frame A thus the x-axis of Frame B points to my point.

Desired situation.

I know transformation matrices and location of point. Which math should I do exactly to calculate how much rotation do I need to rotate Frame A ?

1

There are 1 best solutions below

2
On BEST ANSWER

Let frame $A$ be specified by vector $d_1$ and rotation matrix $R_1$ such that

$p_0 = d_1 + R_1 p_1 \hspace{48pt} (1)$

where $p_0$ is the world coordinate vector, and $p_1$ is the coordinate vector with respect to frame $A$. Frame $B$ is the child of frame $A$, thus

$ p_1 = d_2 + R_2 p_2 \hspace{48pt}(2)$

where $p_2$ is the coordinate vector with respect to frame $B$.

Let $P$ be the world coordinate of the given fixed point, then

$P = d_1 + R_1 (d_2 + R_2 p_2 ) \hspace{48pt}(3)$

Since $p_2$ is along the $x$-axis of the child frame $B$, then

$p_2 = t \begin{bmatrix} 1 \\ 0 \\ 0 \end{bmatrix} = t v \hspace{48pt}(4)$

Plug this into $(3)$:

$P = d_1 + R_1 d_2 + t R_1 R_2 v \hspace{48pt}(5) $

Here $R_1$ is the desired rotation matrix not the starting one. $t$ and $R_1$ are unknown in $(5)$.

From $(5)$ it follows that

$ P - d_1 = R_1 ( d_2 + t R_2 v ) \hspace{48pt}(6) $

Since $R_1$ is a rotation matrix, then

$ \| P - d_1 \| = \| d_2 + t R_2 v \| \hspace{48pt}(7) $

This can be used to determine $t$ explicitly using dot product as follows:

$ (P - d_1) \cdot (P - d_1) = (d_2 + t R_2 v) \cdot (d_2 + t R_2 v) \hspace{48pt} (8) $

And taking the positive root of this quadratic equation. Now define

$ q_1 = d_2 + t R_2 v \hspace{48pt} (9a)$

$ q_2 = P - d_1\hspace{48pt} (9b)$

then,

$ q_2 = R_1 q_1 \hspace{48pt}(9c) $

where both $q_1$ and $q_2$ are known vectors.

The solution for $R_1$ satisfying $(9c)$ is not unique; there is an infinite number of possible rotation matrices. To generate the $R_1$ with minimum rotation angle, we take the axis of its rotation to be

$ a = \dfrac{q_1 \times q_2 }{\| q_1 \times q_2 \|} \hspace{48pt}(10) $

and the angle of rotation is

$ \theta = \cos^{-1} ( q_1 \cdot q_2 )\hspace{48pt}(11) $

Now we can use the Rodrigues' rotation matrix formula, which is

$ R_1 = {a a}^T + (I - {aa}^T) \cos \theta + S_a \sin \theta \hspace{48pt}(12) $

Matrix $S_a = \begin{bmatrix} 0 && - a_z && a_y \\ a_z && 0 && -a_x \\ -a_y && a_x && 0 \end{bmatrix} \hspace{48pt}(13) $

We now have one possible desired rotation matrix. Finally, let's say we started with the original rotation matrix for the frame as $R_{1O}$, and we want to apply rotation $R^*$ with respect to the world coordinate system to $R_{1O}$ that modifies it to the $R_1$ that we derived, the relation between them is

$ R_1 = R^* R_{1O} \hspace{48pt} (14) $

Hence, the required rotation is

$R^* = R_1 R_{1O}^T \hspace{48pt} (15)$