Rotation of $3$-dimensional space vectors

213 Views Asked by At

Assuming there are two vectors $P(x_p,y_p,z_p)$ and $Q(x_q,y_q,z_q)$ originating from the origin. Now, if I rotate vector $P$ to another position in space and obtain the coordinates $P'(x_p',y_p',z_p')$, how can I use the same rotation rule to obtain the coordinates of the rotated vector $Q'$? Can anyone provide me with some assistance?

for example, $P=(4,0,0)$, when we rotate $P$, assume we get $P′=(2,2,2\sqrt{2})$ , so if $Q=(1,2,3)$ , what $Q'$ is ?

2

There are 2 best solutions below

9
On BEST ANSWER

Assuming $P$ is not parallel to $P'$, the unit-length axis of rotation is $k=\frac{P\times P'}{\lvert P\times P' \rvert}$, where $\times$ denotes the vector cross product. To find the angle of rotation, use dot product property $P \cdot P'=\lvert P\rvert\lvert P'\rvert \cos(\theta) $ to find the angle $\theta=\arccos\left(\frac{P\cdot P'}{\lvert P \rvert \lvert P' \rvert}\right)$ between $P$ and $P'$.

According to the "Matrix Notation" section of this Wikipedia article, the corresponding rotation matrix $R(k,\theta)$ is given by expression $I+\sin(\theta)[ k]_{\times}+(1-\cos(\theta))[k]_{\times}^2$, where $I$ is the identity matrix and the notation $[\cdot]_{\times}$ is explained here. This expression for $R$ is the referred to as the "matrix form of Rodrigues' rotation formula."

In other words, $Q'=R(k,\theta)Q$.

For speed, however, a computer implementation of this sort of axis-angle rotation should use quaternions instead of rotation matrices.

Edit: As noted by @peterwhy in the comments below, the above answer assumes that $P$ is not parallel to $P'$ and that we are looking for the unique axis of rotation $k$ and angle $\theta\in(0,\pi)$ such that the space curve $R(k,t)P$ from $P$ to $P'$ is a subset of the plane $\text{span}(P,P')$, where $t\in[0,\theta]$.

If we remove the 'space curve' requirement, we can uniquely determine a rotation axis $k$ and angle $\theta\in(0,\pi)$ given two pairs of vectors $P_1, P_1'$ and $P_2, P_2'$ such that $P_1,P_1'$ are not parallel and $P_2,P_2'$ are not parallel and $P_2$ and $P_2'$ do not have mirror symmetry over the plane bisecting $P_1$ and $P_1'$, i.e., $P_2'\neq 2 \frac{X\cdot P_2}{X\cdot X}X -P_2$, where $X=P_2-\left(P_2\cdot \frac{P_1'-P_1}{|P_1'-P_1|}\right)\frac{P_1'-P_1}{|P_1'-P_1|}$, the projection of $P_2$ onto the plane bisecting $P_1$ and $P_1'$.

Now, for convenience, let $k_0=\frac{(P_1'-P_1)\times(P_2'-P_2)}{|(P_1'-P_1)\times(P_2'-P_2)|}$. Assuming that $P_1,P_1'$ are not parallel and $P_2,P_2'$ are not parallel, if any non-undefined entry in element-wise division $\frac{k_0}{(P_1-(P_1\cdot k_0)k_0)\times(P_1'-(P_1'\cdot k_0)k_0)}$ is positive, $k=k_0$. Otherwise, $k=-k_0$. The corresponding angle $\theta$ is given by $\theta=\arccos\left(\frac{(P_1-(P_1\cdot k)k)\cdot(P_1'-(P_1'\cdot k)k)}{|(P_1-(P_1\cdot k)k)||(P_1'-(P_1'\cdot k)k)|}\right)$. If $\arccos\left(\frac{(P_1-(P_1\cdot k)k)\cdot(P_1'-(P_1'\cdot k)k)}{|(P_1-(P_1\cdot k)k)||(P_1'-(P_1'\cdot k)k)|}\right)\neq\arccos\left(\frac{(P_2-(P_2\cdot k)k)\cdot(P_2'-(P_2'\cdot k)k)}{|(P_2-(P_2\cdot k)k)||(P_2'-(P_2'\cdot k)k)|}\right)$, however, there is no axis or angle sending $P_1$ to $P_1'$ and $P_2$ to $P_2'$.

Note that there is likely a faster way than the one shown here to compute $k$ and $\theta$ under these new assumptions.

Edit 2: If instead given that $P_1=P_1'$ and $P_2$ is not parallel to $P_2'$, the method above the first edit section can be used on $P_1,P_1'$ to obtain $k$ and $\theta$. If $k$ is not parallel to $P_2\times P_2'$, however, there is no axis or angle sending $P_1$ to $P_1'$ and $P_2$ to $P_2'$.

If instead $P_1=P_1'$ and $P_2=-P_2'$, $k=\frac{P_1}{|P_1|}$ and $\theta=\pi$.

If instead $P_1=-P_1'$ and $P_2=-P_2'$, $\theta=\pi$ and $k=\frac{P_1\times P_2}{|P_1\times P_2|} $.

Finally, if instead $P_1$ is not parallel to $P_1'$ and $P_2=-P_2'$, $\theta = \pi$ and $k=\frac{P_2\times(P_1'-P_1)}{|P_2\times(P_1'-P_1)|}$.

I can go into more detail regarding the derivation and intuition behind the statements in "Edit" and "Edit 2" at @ZHIHA's request.

8
On

As peterwhy noted in his comments, an axis of rotation for the pair $P$ and $P'$ is any line that lies in the perpendicular bisecting plane of the line segment $PP'$. This plane has the equation

$ n \cdot (r - m ) = 0 $

where $r = [x,y,z]^T , n = P - P' , m = \dfrac{1}{2} (P + P') $

To specify the axis, pick a point in this plane, any point. Let's call it $P_0$. This will be a point through which the axis passes. Also, pick a direction for the axis line. This can be found as follows

$ a = \cos \psi \ u_1 + \sin \psi \ u_2 $

where $ \psi $ is arbitrary, and $u_1, u_2$ are two mutually perpendicular unit vectors that are also perpendicular to $n$, that is,

$ u_1 \cdot n = u_2 \cdot n = u_1 \cdot u_2 = 0 $ and $ u_1 \cdot u_1 = u_2 \cdot u_2 = 1 $

Next, we have to find the angle of rotation. This is found by projecting the points $P$ and $P'$ onto the plane passing through $P_0$ and having a normal vector $a$, or equivalently projecting vectors $P_0 P $ and $P_0 P'$ onto the plane passing through the origin and perpendicular to the axis line of action $a$. The projection matrix is

$ \mathbf{U} = ( I_3 - {a a}^T ) $

Hence, we have the following two vectors,

$ w_1 = \mathbf{U} (P_0 P) $ and $w_2 = \mathbf{U} (P_0 P') $

The angle of rotation $ \phi $ satisfies

$ w_1 \cdot w_2 = \| w_1 \| \| w_2 \| \cos \phi $

This gives $ \phi $ up to a sign. To determine the sign of $\phi$ form the vector

$ V = w_1 \times w_2 $

If $ a \cdot V \gt 0 $ then $\phi \gt 0$ and if $ a \cdot V \lt 0 $ then $\phi \lt 0$.

That's all we need to find a possible image of the point $Q$. This follows from Rodrigues' Rotation Formula in which the image of vector $v$ is $v'$ given by

$ v' = v \cos \phi + (a \times v) \sin \phi + a ( a \cdot v) (1 - \cos \phi) $

This formula is for a vector $v$ having its tail at the origin, and an axis of rotation $a$ (a unit vector) that passes through the origin.

In our context, the above formula has to be modified slightly, to take into consideration that our axis of rotation passes through $P_0$, so by shifting everything by $-P_0$, rotating, then shifting back to $P_0$, we get the final form of the image $Q'$ as follows:

$ Q' = P_0 + (Q - P_0) \cos \phi + (a \times (Q - P_0)) \sin \phi + a ( a \cdot (Q - P_0)) (1 - \cos \phi) $