Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a 3D point that is rotated about the $x$-axis and after that about the $y$-axis. I know the result of this transformation. Is there an analytical way to compute the rotation angles?

$$ v'=R_y(\beta)*R_x(\alpha)*v $$ Here, $v$ and $v'$ are known and I want to compute $\alpha$ and $\beta$. $R_x$ and $R_y$ are the rotation matrices about the x and y axis respectively. The overall matrix will then be:

$$ R=\begin{pmatrix} \cos \beta & \sin\alpha * \sin\beta & \cos\alpha * \sin\beta \\ 0 & \cos \alpha & -\sin\alpha \\ -\sin\beta & \cos\beta * \sin\alpha & \cos\alpha * \cos\beta \end{pmatrix} $$

share|cite|improve this question
You can use law of cosines. Say $v=(x,y,z)$ and $R_x(\alpha)v=(x,y^\prime,z^\prime)$. Draw the triangle with vertices $A=(x,y,z)$, $B=(x,y^\prime,z^\prime)$, and $C=(x,0,0)$. Then $\angle C$ is $\alpha$. You can do the same process for $\beta$. – icurays1 Nov 12 '12 at 18:27
Correct me if I am wrong, but this cannot work because the second rotation (about the y axis) will change the z-coordinate. Therefore, the angle you described is not the correct one. – Nico Schertler Nov 12 '12 at 19:36
True, but all you need to get the first angle is the final $y$ coordinate. The intermediate $z$ coordinate $z^\prime$ just helps establish $\alpha$. Your second triangle would have vertices $(x,y^\prime,z^\prime)$ (the location after the $x$ rotation), $(0,y^\prime,0)$, and $(x^\prime,y^\prime,z^{\prime\prime})$. This last coordinate is the final location of your point. – icurays1 Nov 12 '12 at 19:42
Yes, but how do I apply law of cosines, if I don't know the intermediate position? – Nico Schertler Nov 12 '12 at 19:58
You know the distance to the $x$-axis though, and the $x$ rotation doesn't change this distance. I.e. $r=\sqrt{z^2+y^2}=\sqrt{y^{\prime^2}+z^{\prime^2}}$. You can get $z^\prime$ from this, up to a sign (the sign doesn't matter - the problem doesn't have a unique solution anyway). – icurays1 Nov 12 '12 at 20:03
up vote 2 down vote accepted

Rotation about the $y$ axis won't change the $y$ coordinate anymore, so the first rotation has to get that coordinate right straight away. There are in general two angles that do the job, but there might be none, namely if $\sqrt{v_y^2+v_z^2}<|v'_y|$. If there are such angles, then for each there will be a unique rotation about the $y$ axis that gets the vector to the destination $v'$, provided we had $|v|=|v'|$ to begin with, which is of course a necessary condition to succeed with any number of rotations fixing the origin. You can easily write down the required angles using inverse trigonometric functions.

share|cite|improve this answer
I also thought about beginning with the y-coordinate. But I am somehow stuck at solving $v'_y=cos\alpha*v_y-sin\alpha*v_z$. – Nico Schertler Nov 12 '12 at 19:42
@NicoSchertler Put $v_y+v_z\mathbf i=r\exp(\beta\mathbf i)$ with $r,\beta\in\mathbf R$, then you want $v'_y=\operatorname{Re}(\exp(\alpha\mathbf i)(v_y+v_z\mathbf i))$ which gives $\frac{v'_y}r=\cos(\alpha+\beta)$, and this is solved by $\alpha=\pm\arccos(\frac{v'_y}r)-\beta$. – Marc van Leeuwen Nov 13 '12 at 9:04

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.