# Rotation matrix convention; successive rotations in intermediate coordinate systems or not

I am getting very confused about the different conventions used for rotation matrices. Thing is I want to accomplish (3) successive rotations each time in the newly defined coordinate system. I use this convention for a rotation matrix:

$$R_{21} = \begin{bmatrix} \hat{u} & \hat{v} & \hat{w} \end{bmatrix} = \begin{bmatrix} u_x &v_x & w_x \\ u_y & v_y & w_y \\ u_z & v_z & w_z \\ \end{bmatrix}$$

Meaning that the x, y and z vector of the new $\underline{e}_2$ coordinate system are given column-wise.

If I then define three successive rotations in the order $zyx$ / yaw pitch roll / $\psi \theta \varphi$ with:

$$R(\psi) = \begin{bmatrix} \cos(\psi) & -\sin(\psi) & 0 \\ \sin(\psi) & \cos(\psi) & 0 \\ 0 & 0 & 1 \\ \end{bmatrix}$$ $$R(\theta) = \begin{bmatrix} \cos(\theta) & 0 & \sin(\theta) \\ 0 & 1 & 0 \\ -\sin(\theta) & 0 & \cos(\theta) \\ \end{bmatrix}$$ $$R(\varphi) = \begin{bmatrix} 1 & 0 & 0 \\ 0 & \cos(\varphi) & -\sin(\varphi)\\ 0 & \sin(\varphi) & \cos(\varphi) \\ \end{bmatrix}$$

Then I can calculate the final coordinate system $\underline{e}_4$ using:

$$R_{41} = R(\varphi) R(\theta) R(\psi)$$

Unfortunately this results in each rotation around the initial coordinate system $\underline{e}_1$, which is what I do not want. I require $R(\psi)$ to rotate around the z axis of $\underline{e}_1$, $R(\theta)$ around the y axis of $\underline{e}_2$ and $R(\varphi)$ around the x axis of $\underline{e}_3$, together resulting in $\underline{e}_4$.

I guess this has something to do with active/passive rotations (e.g. vector or coordinate system rotations). I achieve what I want by doing: $$R_{41} = \left( R(\varphi)^T R(\theta)^T R(\psi)^T \right) ^T$$

But this is a rather ugly way, nor do I fully understand why this is correct. Who can explain me what happens? And who can recommend me a better approach?

Second thing is pre-multiplication versus post-multiplication when dealing with column vectors and row-vectors (seen in the context of the above). How do I transform a column vector to $\underline{e}_4$ taken into account that each successive rotation has to be around the newly defined coordinate system? Similar for a row-vector. Is this correct (for a row vector): $$\vec{w}_2 = \vec{w}_1 R_{41}^T$$ And for column vectors: $$\vec{v}_2 = R_{41} \vec{v}_1$$

Thanks for your help in this!

Simply reverse the order in which you multiply your matrices:

$$R_{41}=R(\psi)R(\theta)R(\varphi)$$

To understand the why: $R(\varphi)$ has columns which contain the basis of the fouth system, expressed in coordinaes of the third. So when you multiply a coordinate vector in the fourth system from the right, you obtain the representation in the third. By a similar consideration, $R(\theta)$ will turn that representation into that for the second and eventually via $R(\psi)$ into the original coordinate system.

So as you can see, if you have the transpose of a product, and change that into a product of transposed factors, then you have to reverse the order. This is the reason why the formula you gave for $R_{41}$ is essentially just a reversal of factors. It also verifies your operations on row vectors:
$$\vec w_2 = \vec v_2^T = \left(R_{41}\vec v_1\right)^T = \vec v_1^TR_{41}^T = \vec w_1R_{41}^T$$