Rotate a vector towards a point

2.6k Views Asked by At

I'm trying to figure out how to rotate a vector towards a certain point in a 3D plane, but I can't seem to find a solution. Here's the problem.

From a given position $P(x_P,y_P,z_P)$, vector $\vec{f}$ originates, with $\vec{f}=\begin{pmatrix} x_f\\y_f\\z_f \end{pmatrix}$. Somewhere else in the plane is point $M(x_M,y_M,z_M)$. Now I'm trying to figure out how to, given an angle $\theta$, one could find a vector $\vec{f'}$ that's basically $\vec{f}$ rotated $\theta$ towards $M$.

2

There are 2 best solutions below

0
On

The Axis of Rotation is the cross-product of the before and after vectors.

The Angle of Rotation is the $ cos^{-1}$ of the dot-product of normalized before and after vectors.

You may also try looking at the StackExchange Computer Graphics

2
On

Here is a simple, explicit way: Let $\vec{v} := M-P$ and then $\vec{g} := \vec{f}\times ( \vec{v} \times \vec{f} )$. Now $\vec{g}$ is orthogonal to $\vec{f}$ and lies in the plane spanned by $\vec{v}$ and $\vec{f}$. Now normalize $\vec g_0 = \frac{|\vec f|}{|\vec g|}\vec g$ to the length of $\vec f$. Then $f' = \cos(\theta) \vec f + \sin(\theta) \vec g_0$.

How do we know we have not rotated in the wrong direction? By a well kown vector identity, $\vec a\times(\vec b\times \vec c) = (\vec a\cdot \vec c)\vec b - (\vec a \cdot \vec b)\vec c$, thus $\vec{v}\cdot\vec{g} = |\vec{f}|^2 |\vec{v}|^2 - (\vec{f} \cdot \vec{v})^2$, which is non-negative by Cauchy's inequality, hence the angle between $\vec g$ and $\vec v$ is acute. This means that $\vec v$ and $\vec g$ lie in the same half-plane with respect to $\vec f$.