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.
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.