# Rotation matrix in order to rotate orthogonal vectors onto x-axis, y-axis, etc…

Assume that I have a set of $n$ orthogonal vectors in $n$-dimensional space such that they span the whole space. These vectors are of arbitrary length and are not necessarily unit vectors.

How do I construct a rotation matrix that will rotate the vectors onto the x-axis, y-axis, z-axis, etc... while preserving their original length?

I intend to use this matrix to rotate an entire space.

• Do the vectors have unit length? If so, then the matrix with the vectors as columns will take the standard basis to the set of vectors. The inverse of the matrix will go the other way, or take the vector set to the standard basis. – Paul Aljabar May 25 '17 at 19:19
• @PaulAljabar no, the vectors have arbitrary length – Paul Terwilliger May 25 '17 at 19:27
• I should have added that, with the assumption that the orthogonal vectors have unit length, the inverse of the above matrix will be its transpose. – Paul Aljabar May 25 '17 at 19:28
• Okay, each vector will need to be scaled first to obtain an orthonormal set ... This transformation will need to be concatenated with the one above. – Paul Aljabar May 25 '17 at 19:30
• okay, so how is this done? – Paul Terwilliger May 25 '17 at 19:31

Let $v_1,\dots,v_n$ be your $n$ vectors. Recalling that the columns of a transformation matrix are images of basis vectors, the matrix that maps the standard basis to these vectors is $$\begin{bmatrix}v_1&\cdots&v_n\end{bmatrix}.$$ Since we want to preserve lengths, we normalize each of the $v_k$ before assembling them into this matrix. The matrix that maps the $v_k$ onto the coordinate axes is then the inverse of this matrix, but because we’ve assumed that the $v_k$ are orthogonal, its inverse is simply its transpose, so the matrix that we’re looking for is $$R=\begin{bmatrix}{v_1^T\over\|v_1\|} \\ \vdots \\ {v_n^T\over\|v_n\|}\end{bmatrix},$$ i.e., the $k$th row of the desired transformation matrix is $v_k$ normalized. Note, however, that although $R$ is an orthogonal matrix, for it to be a rotation we must also have $\det R=1$, which means that $(v_1,\dots,v_n)$ must form a right-handed basis for $\mathbb R^n$.

Let $\mathbf{v}_1, \ldots, \mathbf{v}_n$ be the set of orthogonal vectors. Let $d_1, \ldots, d_n$ be the lengths of the vectors (all $d_i \ne 0$). Let $\hat{\mathbf{u}}_1, \ldots, \hat{\mathbf{u}}_n$ be the unit vectors obtained from the original set of vectors after dividing by each of the $d_i$'s.

Let $U$ be the matrix formed by taking the $\hat{\mathbf{u}}_i$'s as its columns. $U$ is an orthogonal matrix i.e. $U U^T = I$.

Going from the standard basis $\hat{\mathbf{e}}_1, \ldots, \hat{\mathbf{e}}_n$ to the original set, we need to scale each $\hat{\mathbf{e}}_i$ by $d_i$ first then multiply by $U$.

The scaling can be achieved by multiplying by a diagonal matrix $D$ which has $D_{ii} = d_i$ and $D_{ij} = 0$ for $i \ne j$.

So transforming from the standard basis to the set of $\mathbf{v}_i$'s is achieved by multiplying by $D$ then $U$ i.e. by the matrix $M = U D$.

Going the other way is achieved by multiplying by $M^{-1} = D^{-1} U^{-1}= D^{-1} U^{T}$. The matrix $D^{-1}$ is also diagonal and has its $i^{th}$ diagonal entry as $1/ d_{i}$.

If one wants to map the vectors to the standard basis without changing the length then applying $U^T$ is sufficient.

• I think you might have misinterpreted the OP’s question. It seems that he wants to map the vectors onto the corresponding axes, but preserve their lengths, i.e., $\mathbf v_k\mapsto d_k\hat{\mathbf e}_k$ and not $\mathbf v_k\mapsto \hat{\mathbf e}_k$ – amd May 25 '17 at 20:31
• Okay, no problem, have modified for either case ... – Paul Aljabar May 25 '17 at 20:35