How to determine the compensation in an axis while rotating a vector in order to draw a linear path?

122 Views Asked by At

Suppose we have a 3D vector that can be rotated around two axis (a, b in fig.). So let's going to say we just made an small rotation to left in the axis $a$, the vector will be pointing to lower $z$-coordinate. And what I want to know is, if is there a way to calculate the increment in $b$ that I should do depending the amount of rotation in $a$ and the initial orientation of the vector, for drawing a imaginary straight line (keeping $z$-coordinate constant as shown in fig. with green line).

image

What I have found is that given the initial orientation and the increment that will be made on $a$, it's going to be the increment I need to add to $b$. But this little increment I found was a guessed value (not properly calculated).

A fast example would be:

Initial orientation of "b": 59.21º

Increments on "a": 0.01º

Estimated guessed compensation in $b$ in order to keep $z$-coordinate constant: $\tan(0.0036º)$

I have an scenario where I'm simulating this case, and hence tested the above example. Thanks in advance guys.

1

There are 1 best solutions below

0
On BEST ANSWER

We can assume that the parametric equation of the line to be traced is given by $p(t) = p_0 + t u \hspace{24pt} (1)$

where $u$ is the direction vector of the line. If the tracing vector has its origin at point $P$, then vector pointing from $P$ to $p(t)$ is given by

$v(t) = p(t) - P = p_0 - P + t u \hspace{24pt} (2) $

Let's normalize this vector as $w(t) = v(t) / | v(t) | \hspace{24pt} (3) $

Before $t = 0$, this vector is pointing in the direction given by the unit vector $w_1 = \dfrac{p_0 - P}{| p_0 - P| }$

We want to find $\phi_1$ and $\phi_2$ (functions of $t$ ) such that

$w(t) = R_b(\phi_2) R_a(\phi_1) w_1 \hspace{24pt} (4)$

where the axes $a$ and $b$ are fixed vectors in space. Note that $w(t)$ and $w_1$ are both unit vectors.

From equation $(4)$, it follows that

$ q = R_b^T (\phi_2) w(t) = R_a (\phi_1) w_1 \hspace{24pt} (5) $

Rotation preserves the angle between the rotated vector and the axis of rotation.

Therefore, we want the angle between $R_a (\phi_1) w_1$ and axis $b$ to be the same as the angle between $w(t)$ and $b$

Using the dot product this can be expressed as

$ b^T R_a(\phi_1) w_1 = b^T w(t) \hspace{36pt} (6) $

Recall that the rotation matrix about an axis $a$ is given by

$R_a (\phi_1) = a a^T + (I - a a^T) \cos \phi_1 + S_a \sin \phi_1 \hspace{36pt} (7)$

where $S_a y = a \times y $ for any vector $y$, i.e.

$S_a = \begin{bmatrix} 0 && - a_z && a_y \\ a_z && 0 && -a_x \\ -a_y && a_x && 0 \end{bmatrix} $

Premultiplying $(7)$ by $b^T$ and post-multiplying by $w_1$, and plugging that in $(6)$ generates a scalar trigonometric equation,

$ c_1 \cos \phi_1 + c_2 \sin \phi_1 = c_3 \hspace{36pt} (8) $

where

$c_1 = b^T (I - {a a}^T) w_1 ,\hspace{6pt} c_2 = b^T S_a w_1 , \hspace{6pt} c_3 = b^T w(0) - b^T {a a}^T w_1 $

Equation $(8)$ can be solved quite easily (by combining the $\cos$ and $\sin$ terms ) and will generally have two solutions.

Choose one of the solutions $\phi_1$ and compute $R_a(\phi_1)$, and plug it in equation $(5)$ to compute the rotated vector $q$.

We still have to find $\phi_2$. This can be done in the same way as we found $\phi_1$, namely, from (5), we want the angle that $R_b^T (\phi_2) w(t) $ with vector $a$ , to be the same as the angle that vector $w_1$ makes with vector $a$. Thus

$ a^T R_b^T (\phi_2) w(t) = a^T w_1 \hspace{36pt} (9) $

And the same procedure as before is used to find the two values of $\phi_2$. Now that we have two values of $\phi_1$ and $\phi_2$ we have to mix and match the values to obtain only two possible solutions (not four), using equation $(5)$.

Now, we'll differentiate the above obtained equations with respect to the parameter $t$.

So we have, from equations (1) and (3),

$w(t) = v(t) / | v(t) | = v(t) / \sqrt(v^T v)$

Differentiate this

$\begin{equation} \begin{split} w'(t) &= v'(t) / |v(t) | + v(t) (-1/(v^T v) )(1/(2 \sqrt{v^T v} ) (2 v(t)^T v'(t) ) \\ &= v'(t) / |v(t) | - v(t) v(t)^T v'(t) / (v^T v)^(3/2)\\ &= 1/|v(t)| ( I - v v^T / v^T v ) v'(t) \\ &= 1/| v(t) | ( I - v v^T/ v^T v ) u \hspace{36pt} (10) \end{split} \end{equation}$

From equation (6),

$ b^T R_a(\phi_1) w_1 = b^T w(t) \hspace{36pt} (6) $

Differentiating,

$b^T ( \dfrac{dR_a}{d\phi_1} \dfrac{ d\phi_1}{dt} ) w_1 = b^T w'(t) \hspace{36pt} (11) $

from which we can find $\dfrac{d \phi_1}{dt} $

similarly

$ a^T R_b^T (\phi_2) w(t) = a^T w_1 \hspace{36pt} (9)$

Differentiating,

$ a^T ( \dfrac{dR_b^T}{d\phi_2} \dfrac{d\phi_2}{dt} w(t) + R_b^T w'(t) ) = 0 \hspace{36pt} (12) $

Note that $R_b^T(\phi_2) = R_b(- \phi_2 ) $

So, in summary, to find the incremental $d \phi_1 $ and $d \phi_2 $ :

  1. Find $w(t)$, $\phi_1$ and $\phi_2$ as outlined above.

  2. Find the derivative $w'(t)$, as given by equation $(10) $

  3. Find $\dfrac{ d\phi_1}{dt} $ from equation $(11)$

  4. Find $\dfrac{ d\phi_2}{dt} $ from equation $(12) $

  5. Use $ d\phi_1 = \dfrac{ d\phi_1}{dt} dt $ and $ d \phi_2 = \dfrac{ d\phi_2}{dt}dt $