Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

HI I am wondering if there is a unique matrix that maps $(x_1,y_1,z_1)$ into $(x_2,y_2,z_2)$. These two vectors have equal magnitude and are defined in orthogonal 3-D basis. If there is a unique solution how can I find it by considering rotation about all three orthogonal basis?

share|improve this question

4 Answers 4


For example, let $p_1 = (x_1,y_1,z_1)^T$, and $d_1 = (x_2,y_2,z_2)^T$. Choose $p_2,p_3 \in \mathbb{R}^3$ so that $p_1, p_2, p_3$ are orthogonal. Let $d_2, d_3$ be arbitrary. Then define the matrix $$A = \frac{1}{\|p_1\|^2} d_1 p_1^T + d_2 p_2^T + d_3 p_3^T $$

It is easy to check that $A p_1 = d_1$. Since $d_2, d_3$ are arbitrary, it is clear that the transformation that maps $p_1$ into $d_1$ is not unique.

In fact, all transformations $A$ that satisfy $A p_1 = d_1$ can be expressed in this form with appropriate choice of $d_2,d_3$. If the $p_k$ and $d_k$ are chosen to be orthonormal, then the resulting $A$ will be a rotation (possibly improper).

share|improve this answer

There are many such matrices. If you find a single matrix $M$ which maps $v_1=(x_1,y_1,z_1)$ to $v_2=(x_2,y_2,z_2)$, then we could multiply such an $M$ by a rotation matrix whose axis goes along $v_2$.

To get a matrix $M$ we can use $M=1/(v_1 * v_1)v_2^t v_1$. Here by $v_1*v_1$ I mean dot product of $v_1$ with itself, and by $v_2^t$ I mean transpose of $v_2$, which would make it into a column vector. That way $v_2^t v_1$ comes out to be a matrix. You have to use $v_1^t$ when computing the result of multiplying $M$ by $v_1$.

share|improve this answer

coffeemath explained why you cannot find an unique such matrix.

On another hand, since you are interested in rotations about the axes, there exists a pair of rotations $R_1, R_2$ about two of the axes of your choices, so that $v_2=R_2 R_1 v_1$. Moreover, if you fix the axes, and the order, I think there are exactly two such rotations.

To understand why, just think in spherical coordinates, where the angles are expressed with respect to the two axes you chose...

Then the first vector is $(R, \phi_1, \theta_1)$ and the second vector is $(R, \phi_2, \theta_2)$, so a rotation if angle $\phi_1-\phi_2$ and one of angle $\theta_1-\theta_2$ should do it.

The second possibility comes from the fact that you can also do a rotation of more than $180^\circ$ with respect to the second angle....

share|improve this answer
Suppose your choice is to rotate around x axis, then around y axis. And suppose v_1 is close to the unit vector for the x axis, while v_2 is close to the unit vector for the y axis. Then after a rotation around the x axis, we arrive at a vector w which is still near the unit vector of the x axis. When such a vector is rotated around the y axis it cannot end up near the goal vector v_2. The rotation about the y axis will preserve whatever angle w now makes with the y axis. –  coffeemath Oct 10 '12 at 2:12
I think the spherical coordinate approach makes it clear one can use first a rotation about the z axis, and then one more rotation. However, once the rotation about the z axis has been done, in such a way as to change the longitude of v_1 to that of v_2 (arriving at say w) there is another rotation to go. In order to now rotate w into v_2 typically the origin, w, and v_2 make a plane, and the second rotation must be around the perpendicular to that plane, which is not typically one of the three axes (x or y or z). –  coffeemath Oct 10 '12 at 2:29

In the following, c stands for cosine and s for sine (of any angle $\theta$) $$\pmatrix{c & s\\ -s &c} \pmatrix{x_1 \\ y_1}$$ So in particular, we have that $s^2 + c^2 = 1$. The matrix multiply represents the rotation about the z-axis. The magnitude of the vector is preserved as such: $$\left|\pmatrix{x_1 \\ y_1}\right|^2 = x_1^2 + y_1^2 \quad \text{this is the original magnitude}$$ $$\left|\pmatrix{cx_1 +sy_1\\ -sx_1 + cy_1}\right|^2 = (cx_1 +sy_1)^2 + (-sx_1 + cy_1)^2$$ $$=(c^2x_1^2+s^2y_1^2+2csx_1y_1) +(s^2x_1^2+c^2y_1^2-2csx_1y_1)$$ $$=c^2(x_1^2+y_1^2)+s^2(x_1^2+y_1^2)$$ $$=(c^2+s^2)(x_1^2+y_1^2)$$ $$=x_1^2+y_1^2 \quad \text{and the magnitude is unchanged}$$

You can apply this form of matrix a few times, starting with your first point in 3-D, and reach the desired value in one coordinate at a time. So for example, to rotate about the y axis: $$\pmatrix{c & 0& s\\0&1&0\\-s&0&c}\pmatrix{x \\ y \\ z}$$ You would only need to do this twice, as the final value would by necessity match as desired, since the magnitudes are the same for the two points.

To find c and s, use $$c=\frac{x_1}{\sqrt{x_1^2+y_1^2}} \quad\text{and}\quad s=\frac{y_1}{\sqrt{x_1^2+y_1^2}}$$

HINT: any two values instead of $x_1$ and $y_1$ in that formula gives a valid c and s for a rotation matrix.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.