0

Given normalized vectors $U=(u_1,u_2,u_3)$ and $V=(v_1,v_2,v_3)$, find a rotation matrix $R$ such that $RV=U$.

I've read these topics: Find a rotation matrix that sends $v$ to $u$

Finding a specific Rotation matrix given a known vector

And many other links but didnt find them very useful.

I'd be glad for help.

  • 4
    With $\vec w = \vec u\times \vec v$ use Rodrigues' rotation formula around $\vec w$ – Cesareo Jun 13 '19 at 21:49
  • Not "finding them very useful" isn't a good enough reason to post what will almost certainly be flagged as a duplicate. You should dig in more. You might find quaternions useful, as they are sometimes easier to invert. – Adrian Keister Jun 13 '19 at 22:01
  • 1
    I've read about quaternions. didnt understand them at all. "didnt find them useful" - too complicated for dummies, and it would be great if this problem made simpler to solve and understand. – Elyasaf755 Jun 13 '19 at 22:08
  • 3
    @Elyasaf755: There's nothing whatsoever wrong with not knowing something. There is something wrong with not wanting to put forth effort to learn, which your comments could be interpreted to mean. Use Cesareo's hint. The cross product will give you the axis of rotation. You can also find the angle of rotation by breaking down $|\vec{u}\times\vec{v}|=|\vec{u}|,|\vec{v}|,\sin(\theta),$ and solving for $\theta.$ Then you can use the Rodrigues formula (there's a wiki page on that) to find the total rotation matrix. – Adrian Keister Jun 13 '19 at 22:13
  • Last comment was useful, thank you! but now i'm facing another problem: What if i wanted to rotate other vectors with the same rotation I applied for V? I mean, let's say that after i used the Rodrigues' rotation formula and happened that the rotation i applied on V was 44 degrees around the X axis, 77 degrees around Y, and 120 degrees around Z. How can i know the rotation I've applied on each axis so I can apply the same rotation (44,77,120) on some other vector V2?

    That's why I asked in the begining for a rotation matrix R such that R*V=U

    – Elyasaf755 Jun 13 '19 at 23:05
  • Then use the same axis and angle for all of the rotations. – amd Jun 14 '19 at 01:26
  • I've calculated the rotation matrix R through the formula given in the Rodrigues' rotation formula wiki page here: https://en.wikipedia.org/wiki/Rodrigues%27_rotation_formula but once I multiply R*V to get U, I get some other vecctor. I used computer to compute R, and I checked my code - its fine. what am I doing wrong? – Elyasaf755 Jun 14 '19 at 08:01
  • I've checked the code deepper, I've found a problem with the Math.sin function in java (which accepts and returns radians). If I perform Math.sin(Math.PI), the result wont be 0. so maybe that is the problem. I've read about it and many people are complaining about it, but couldnt find any good solutions for this. – Elyasaf755 Jun 14 '19 at 12:38

2 Answers2

1

The easiest way, in my opinion, is to use Householder reflection. It is a unitary transformation with the following matrix $$H = I_n - 2\nu\nu^T$$ where $H \in R^n$, $\|\nu\| = 1$ and $n$ is the dimension of the vectors that you deal with. Now, the question is to find the matrix $H$ such that $y = Hx$, with $x,y \in R^n$. Sufficient condition is $\|y\| = \|x\|$ (H is unitary, it does not change the norm) which is provided. So: $$Hx = x - 2\nu\nu^Tx = y$$ $$\nu = \frac{x-y}{2\nu^Tx}$$ since $\nu$ is unit vector: $$\nu = \frac{x-y}{\|x-y\|}$$ If you apply $H$ to any vector in $R^n$, it does not rotate them in the exact same angles as it rotates $x$. Instead, It reflects them with respect to the same plane that $x$ is reflected.

Kurban
  • 129
  • Thank you very much. although - this does not work (maybe the calculation of V are incorrecct?) How can you perform division between vectors? – Elyasaf755 Jun 14 '19 at 13:36
  • You do not have any division between vectors, you calculate $x-y$ and then normalize it. – Kurban Jun 14 '19 at 17:48
  • Your last claim is false. $H$ is, as you say, a reflection in the plane with normal $v$. It doesn’t preserve orientation, and other points will appear to have been rotated by various other angles. This can be salvaged by composing with a second reflection. – amd Jun 15 '19 at 01:20
  • You are right, thanks. It is not a rotation matrix. – Kurban Jun 15 '19 at 08:23
0

Thank you all for the answers.
The Rodrigues' formula did work, so let me try to give the full solution.


The solution:

Given $2$ vectors $\vec V=(v_1,v_2,v_3)$ and $\vec U=(u_1,u_2,u_3)$, we need to to find a rotation matrix $R$ such that $R\cdot$$\vec V=\vec U$

Let $\vec W= (w1, w2, w3)$ be the cross-product $\vec V$$\times$$\vec U$. Normalize it. $\vec W$ is now our rotation axis.

let $K$ be the matrix representation of $\vec W$. $$K = \begin{bmatrix}0&-w3&w2\\w3&0&-w1\\-w2&w1&0\end{bmatrix}$$ The angle $θ$ between the two vectors $\vec U$ and $\vec V$ is:

$$θ = arcsin\Biggl(\frac{ \lVert\vec W\lVert}{\lVert\vec V\lVert\cdot\lVert\vec U\lVert}\Biggl)$$
while $\lVert\vec W\lVert$ is the lengeth of $\vec W$.

Let $I$ be the identity matrix.

The Rodrigues' formula for the rotation matrix R is as follows:

$R = I+sin(θ)\cdot$$K+(1-cos(θ))\cdot$$\mathrm{K}^2$

while $\mathrm{K}^2$ is the multiplication of the matrix K by itself.

Then, you can simply multiply $R$ by any vector to apply the same rotation on it.