# Matrix multiplication order for multiple model transformations

I have a problem in terms of what frame of reference, I should construct, scaling (S), rotation (R) and translation (T) for a model matrix (in that order). Let us assume the use of glm (or glsl), i.e. to mean column major representation.

I believe, it should be a matrix multiplication of:

M = T * R * S // S * R * T is what we want to apply, but due to being column major, the order gets reversed, due to (AB)^T =B^T*A^T


Now, if I have a previous transformation already applied (say M_prev), and I want to apply a transformation M on top of that, then is the correct form:

M_new = M_prev * M // M_new and M_prev are both column major. I'm post multiplying due to being column major, but this is incorrect, I guess?


I believe this is incorrect (at least in some experiments I carried out, please correct me if I'm wrong), and it should be the reverse. What is the flaw in my calculation of M_new?

• Your two examples aren't consistent with one another. If T*R*S means T is being applied after R which is in turn applied after S, then M_prev * M means M_prev is being applied after M; or vice versa, assuming all of your matrices are constructed similarly. Are you expecting that somewhere in between the matrices are being transposed? You mention one set being column-major and another row-major, but it's not clear why your application would be mixing two different matrix conventions. Sep 20, 2017 at 0:38
• All matrices that I'm using are column major. Nothing is row major. I'm trying to understand why the 2nd equation is wrong. I added a comment to further clarify. I'm trying to applying S, then R and then T. But, reversing that order due to column major. Sep 20, 2017 at 0:42
• I further added more. Nothing is row major. Everything is column major. Maybe, I'm doing the 2nd part correct for a 'row major' matrix, but that's what I'm trying to understand. Why is this wrong for column major? Sep 20, 2017 at 0:45
• If the column major order for TRS is "later * earlier" then why would you expect that for M_prev and M it would become "earlier * later"? ie. T is supposed to happen after R, so you put it on the left. M is supposed to happen after M_prev, so why do you put it on the right? If you're using the same matrix convention throughout then your order of multiplication should not change. Where has our reasoning diverged? Sep 20, 2017 at 0:48
• I'll confess I still don't understand what the question or confusion was in the first place, so I'm not sure what needs to be explained in an answer. Sep 20, 2017 at 17:40

M_new = M_prev * M would apply first matrix M then M_prev which is not want what you want - think of them as some transformation matrices, like S, T, R and nothing more ...
Therefore if you want M be applied after 'M_prev' just do
M_new = M * M_prev