Work out the a rotation matrix in this condition

231 Views Asked by At

Let $\textbf{u} = (u_x,u_y,u_z)^T$ such that $\left\lVert \textbf{u} \right\rVert = 1$, and $\textbf{n} = (0,0,1)^T$. I'm trying to work out a rotation matrix $R$ such that

$$ \textbf{n} = R \textbf{u} $$

Given that $$ R = I + \sin(\theta)K + (1-\cos(\theta))K^2 $$

Where $K$ is the skew matrix built upon the rotation axis $\textbf{k}$. I'd do something like the following:

I'd exploit $\cos(\theta) = \textbf{n} \cdot \textbf{u} = u_z$, from there I can work out $\theta$, later I'd define $\textbf{k} = \textbf{u} \times \textbf{v}$. I'll stick these two into the Rodrigues formula and I should get $R$.

Is this procedure correct?

Update:

Figured out that since $u_z = \cos(\theta)$ we have $\sin(\theta) = \sqrt{1-u_z^2}$ therefore the rotation matrix is

$$ R = I + \sqrt{1-u_z^2} K + (1-u_z)K^2 $$

2

There are 2 best solutions below

16
On BEST ANSWER

Your method is good, but the only remark that there are infinitely many rotations that transform one vector $\mathbf{u}$ into other vector $\mathbf{n}$ (see also derive quaternion from rotation matrix, via eigenvector for discussion about relationship of axis and value for rotation angle).
Method of Stijn should provide more solutions.

The other simple solution is for example to rotate about axis $ \mathbf{r}= \mathbf{u}+\mathbf{n}$ by the angle $\pi$ ( draw a picture and you'll see what I mean). If you want now to use Rodrigues formula, the vector $ \mathbf{r}$ requires normalization to unit length, name normalized vector $\hat{ \mathbf r}$.
For this case rotation matrix has a particularly simple form $R=2\hat{ \mathbf r}\hat{ \mathbf r}^T-I$.

The other more general method is to use the equation $N=RU$.
Matrix $N$ can be simply identity matrix $I$ - the last its column is just $\mathbf{n}$ vector, and $U$ is composed from the columns $[ \mathbf{u}_\perp \ \ \mathbf{u}×\mathbf{u_\perp} \ \ \mathbf{u}]$,
where $\mathbf{u}_\perp$ is any unit length vector perpendicular to $\mathbf{u}$.

In this case $I=RU$ and consequently $R=U^{−1}$.

Notice that here you have some degree of freedom in the choice of $\mathbf{u_\perp}$, one of them it can be normalized $\mathbf{n}×\mathbf{u}$.

2
On

I think you are on the right track in principle. However, there is what I believe to be a significantly simpler way to solve this problem.

Rotation matrices are orthogonal matrices with determinant equal to one. If we write the rotation matrix $R$ in the form $$R = \begin{pmatrix}{\bf r}_1^T \\ {\bf r}_2^T \\{\bf r}_3^T \end{pmatrix},$$ where ${\bf r}_1$, ${\bf r}_2$, and ${\bf r}_3$ are three vectors, the equations we want to solve reduce to $${\bf r}_1^T {\bf u} = {\bf r}_2^T {\bf u} = 0, \quad {\bf r}_3^T {\bf u} = 1.$$ In other words, we need to find two vectors ${\bf r}_1$ and ${\bf r}_2$ that are orthogonal to ${\bf u}$, and one vector ${\bf r}_3$ with inner product one with ${\bf u}$.

To make sure that $R$ is orthogonal, these three vectors need to be orthogonal to each other, and have length one. Doing so, $R$ is orthogonal, and its determinant will be $\pm1$. You can then always make sure it is equal to one, by interchanging what you call ${\bf r}_1$ and ${\bf r}_2$, since this flips the sign of the determinant of $R$.

This reduces the problem to some linear equations that you can easily solve. In particular, ${\bf r}_3$ you can just take to be ${\bf u}$, since $||{\bf u}||=1$.