0

I have a vector $(0,0,1)$ and it is rotated about x, then rotated around y and then rotated around the z axis to a new point $(x,y,z)$. In other words.

$\begin{bmatrix} x \\ y \\ z\end{bmatrix} = R_z(\alpha) R_y(\beta) R_x(\gamma) \begin{bmatrix} 0 \\ 0 \\ 1\end{bmatrix}$

Where $R_x, R_y, R_z$ are rotation matrices. How can I find the rotation angles $\alpha, \beta, \gamma$ in terms of final point coordinates $x,y,z$?

  • Im not exactly sure what is meant by "rotation around an axis". But for sure, you can find $3 \times 3$ matrices to represent each of the the rotations. Then multiply the rotation matrices with one another and apply it to $[0,0,1]$ – NazimJ Oct 29 '20 at 15:32
  • 2
    Beware, in 3d the solution is not unique – user619894 Oct 29 '20 at 16:03
  • Thanks, I didn't realize this would not produce a unique solution. How can I find just one solution, thought? I thought I could just multiply the rotation matrices together and apply a solver to solve the 3 equations (1 eqn for each row) simultaneously. But this seems messy.

    Is there a way to take advantage from the fact that the initial vector is perfectly in the z direction?

    – Matthew James Oct 30 '20 at 07:51
  • Similar: https://stackoverflow.com/questions/15022630/how-to-calculate-the-angle-from-rotation-matrix – Matti P. Oct 30 '20 at 10:52

1 Answers1

0

First find the azimuth $\theta$ and elevation $\phi$ and radius $r$ of the final point $(x,y,z)$. Then rotate the the initial point in the x,y plane by the $\theta$. Then rotate that point around the axis perpendicular to the line at the angle of $\theta$. Let this second axis of rotation be defined by the unit vector $u = (u_x, u_y, u_z)$.

First rotation about z axis

$R_z = \left(\begin{array}{ccc} \cos\left(\mathrm{\theta}\right) & -\sin\left(\mathrm{\theta}\right) & 0\\ \sin\left(\mathrm{\theta}\right) & \cos\left(\mathrm{\theta}\right) & 0\\ 0 & 0 & 1 \end{array}\right)$

Second rotation about u axis. In this case the axis of rotation is defined by: $u_x = -\sin(\theta)$, $u_y = \cos(\theta)$, $u_z = 0$.

$R_u=\left(\begin{array}{ccc} \cos\left(\mathrm{\phi}\right)-{u_{x}}^2\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & -u_{z}\,\sin\left(\mathrm{\phi}\right)-u_{x}\,u_{y}\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & u_{y}\,\sin\left(\mathrm{\phi}\right)-u_{x}\,u_{z}\,\left(\cos\left(\mathrm{\phi}\right)-1\right)\\ u_{z}\,\sin\left(\mathrm{\phi}\right)-u_{x}\,u_{y}\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & \cos\left(\mathrm{\phi}\right)-{u_{y}}^2\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & -u_{x}\,\sin\left(\mathrm{\phi}\right)-u_{y}\,u_{z}\,\left(\cos\left(\mathrm{\phi}\right)-1\right)\\ -u_{y}\,\sin\left(\mathrm{\phi}\right)-u_{x}\,u_{z}\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & u_{x}\,\sin\left(\mathrm{\phi}\right)-u_{y}\,u_{z}\,\left(\cos\left(\mathrm{\phi}\right)-1\right) & \cos\left(\mathrm{\phi}\right)-{u_{z}}^2\,\left(\cos\left(\mathrm{\phi}\right)-1\right) \end{array}\right)$

Then to map the vector $(0,0,1)$ to the point $(x,y,z)$ I need to do the following:

${\begin{pmatrix} x\\ y\\ z \end{pmatrix}} = R_u R_z {\begin{pmatrix} 0\\ 0\\ 1 \end{pmatrix}}$

Because the matrices only do rotations, this formula will only work if the magnitude of the vector $(x,y,z)$ is 1