Finding rotate matrix which solves equation

71 Views Asked by At

I try to solve the following problem: given a unit vector v, find rotate matrix R such that R*v = (0,0,..0,1) (vector that it's (n-1) components are 0 and the n'th component is 1). I know that if I hadn't had the request that R is a rotate matrix it would have been simply system of linear equations. Any thoughts of how can I find such a rotate matrix?

Thanks

1

There are 1 best solutions below

3
On BEST ANSWER

Use the Gram-Schmidt process, slightly modified. Start with the $n + 1$ vectors $$ v, e_1, e_2, \ldots, e_n $$ (where $e_i$ denotes the standard basis vector: 0s in all entries, but 1 in the $i$th entry) and call them $v_1, v_2, \ldots, v_{n+1}$.

Apply Gram-Schmidt to get \begin{align} w_1 &= v_1\\ u_1 &= w_1 / \|w_1 \|, \end{align}

as a first step. $u_1$ (which is just $v$, of course) will be the first column of your matrix.

Now apply GS to $v_2$: \begin{align} w_2 &= v_2 - (v_2 \cdot u_1) u_1 \\ u_2 &= w^2 / \| w_2 \| \end{align} and then to $v_3$: \begin{align} w_3 &= v_3 - (v_3 \cdot u_1) u_1 - (v_3 \cdot u_2) u_2 \\ u_3 &= w^3 / \| w_3 \| \end{align} and so on.

If, in the course of doing this, you ever find $w_i = 0$, then throw $v_i$ out of your list and start work with the next item as $v_i$.

In general, this "$w_i = 0$" case happens right at the end: the $n+1$st vector is a linear combination of the previous $n$. But if it happens in the middle, you can just toss out that vector early.

When you're done, the vectors $u_i$ will form the rows of an orthogonal matrix. The vector $v$ is the first row, but reading your question carefully, I see it should be the last: so swap the first and last rows. Now the only question is whether the resulting matrix is a rotation. If the determinant is $+1$, it's a rotation; if not, then negate the first row and it will be.

(A natural question is "if you want $v$ in the last row, why not put it at the end of your list of vectors instead of the start?" Answer: I want $v$ unchanged, and in the GS process, only the first vector survives untouched, and it only does so if it's a unit vector.)