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?

  • \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Sep 20 '17 at 0:38
  • \$\begingroup\$ 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. \$\endgroup\$
    – dev_nut
    Sep 20 '17 at 0:42
  • \$\begingroup\$ 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? \$\endgroup\$
    – dev_nut
    Sep 20 '17 at 0:45
  • \$\begingroup\$ 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? \$\endgroup\$
    – DMGregory
    Sep 20 '17 at 0:48
  • 1
    \$\begingroup\$ 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. \$\endgroup\$
    – DMGregory
    Sep 20 '17 at 17:40

taking into account that matrices are column-major as you said, then yes, it is incorrect.


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


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.