Matrix transformations

81 Views Asked by At

I have to find components of a matrix for 3D transformation. I have a first system in which transformations are made by multiplying:

$M_1 = [Translation] \times [Rotation] \times [Scale]$

I want to have the same transformations in an engine who compute like this:

$M_2 = [Rotation] \times [Translation] \times [Scale]$

So when I enter the same values there's a problem due to the inversion of translation and rotation.

How can I compute the values in the last matrix $M_2$ for having the same transformation?

Thanks

1

There are 1 best solutions below

9
On

I assume you multiply matrices on the left, so that $x$ is mapped to $M_1 x$ and $x$ is a column vector.

Let $T_R(x) = Rx$ be a rotation, and let $T_T(x) = x+b$ be a translation. We have $$ T_R(T_T(x)) = R(x + b) = Rx + Rb\\ T_T(T_R(x)) = T_Rx + b $$ If you want to have the second behave like the first, you have to "prerotate" the translation before applying it. That is, let $T_{T'}(x) = x + Rb$. We then have: $$ T_{T'}(T_R(x)) = Rx + Rb $$ which matches the first output.


In the below, I assume you multiply matrices on the right, so that $x$ is mapped to $x \, M_1$, $x$ is a row vector, and successive transformations are done from left to right.

Let $T_R(x) = xR$ be a rotation, and let $T_T(x) = x+b$ be a translation. We have $$ T_T(T_R(x)) = xR + b\\ T_R(T_T(x)) = (x + b)R = xR + bR $$ If you want to have the second behave like the first, you have to "un-rotate" the translation before applying it. That is, let $T_{T'}(x) = x + bR^{-1} = x+b R^T$. We then have: $$ T_R(T_{T'}(x)) = (x + bR^T)R = xR + bR^T R = Rx + b $$ which matches the first output.