Matrix orientation choice

I noticed transform Matrices in MonoGame are transposed from what is found in literature (example or wikipedia).

  • translations are put in the last column in literature, but in the bottom row in MonoGame.
  • rotations: the -sin() is put in M21, while it is put in M12 in literature

I noticed the very same in .NET WPF.

Anybody knows if this has a specific reason? Or is it just an arbitrary choice?

It effectively changes the order in which to multiply matrices when combining transforms, making the order more intuitive. Maybe that’s a reason?

It’s arbitrary, you can use whichever you want when you design your system.

Matematicians invented those centuries ago and they decided to use one of the two methods. That’s why “literature” usually uses that method.

Computer graphics designers chose one method or another, depending on how they think they’ll behave performance-wise. (SIMD, cache performance, …)

Yes, the XNA/Monogame way means the three (well four) floats that define the translation are together in memory.

It’s like in the old days the Atari ST pixel format put four pixels into a single word where the Amiga split the pixel across bit planes.

So on the amiga you read a word to get the red channel of 16 pixels, then have to read different memory addresses to get the other channels.

Commodore did that because it made sense for the blitter, Atari didn’t have a blitter, so the best they could do was exploit the movp.l instruction on the 68000

Thanks. Haha, this went a bit off topic quite fast, but I understand the link, and it’s interesting to have that background.

So the matrix orientation is to put things together that are commonly needed together. (SIMD can just get the x,y,z,w translation from the matrix in one go). Thanks!