Which rotation matrix for which axis up?

42 Views Asked by At

I am learning how to write 3d transformation matrices for use in Unity.
I found what I needed about translations and scaling, but when it comes to rotations, I've found two opposite examples.

I assume one is made to work in a Y-Up environnement, and the other in Z-Up, but which one is which ?

One says a XYZ rotation uses these matrices :

$$ \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & cos(X) & -sin(X) & 0 \\ 0 & sin(X) & cos(X) & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] * \left[ \begin{matrix} cos(Y) & 0 & sin(Y) & 0 \\ 0 & 1 & 0 & 0 \\ -sin(Y) & 0 & cos(Y) & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] * \left[ \begin{matrix} cos(Z) & -sin(Z) & 0 & 0 \\ sin(Z) & cos(Z) & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] $$

While the other uses the additive inverse of the sinus : $$ \left[ \begin{matrix} 1 & 0 & 0 & 0 \\ 0 & cos(X) & sin(X) & 0 \\ 0 & -sin(X) & cos(X) & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] * \left[ \begin{matrix} cos(Y) & 0 & -sin(Y) & 0 \\ 0 & 1 & 0 & 0 \\ sin(Y) & 0 & cos(Y) & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] * \left[ \begin{matrix} cos(Z) & sin(Z) & 0 & 0 \\ -sin(Z) & cos(Z) & 0 & 0 \\ 0 & 0 & 1 & 0 \\ 0 & 0 & 0 & 1 \\ \end{matrix} \right] $$


EDIT:
To clear things up, this is the environnement I'm willing to work with :
Unity Coordinate system