# DirectX Matrix Multiply

Just in case it's driving you nuts too, I've just rediscovered something. I'd be happy to be proved wrong, but I've been drawing pictures of axes for an hour now (sad, I know), and I'm satisfied I'm right.

You might imagine that...

Matrix m1 = ...

Matrix m2 = ...

Matrix m3 = m1 * m2;

...(I should add in C#) would give you a matrix m3 which represents the results of m1's operations FOLLOWED BY m2's. But no; it's the OPPOSITE, m2 followed by m1.

To say this is counter-intuitive is a massive understatement, and of course if it gets changed 3D worlds everywhere will turn inside out or disintegrate, so live with it we must. I say rediscovered because I remember falling down this same hole a couple of years ago.

There's probably a reasoned argument as to why it's done this way. and I seem to recall GDI+'s matrices do the same thing. Equally I also seem to recall that quaternions in C++ do the opposite; q1 * q2 is q1 followed by q2. So my top tip is next time things look wrong after a matrix calculation, flip the multiplication order and maybe all will be well without you having to write "X", "Y" and "Z" on the edges of a CD cover and invest an hour of your day experiencing the feeling that you may be going mad!