I have followed the tutorial at http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ to implement my 2D camera and everything works just fine. However this leaves me confused. From that implementation i see that first there is the translation applied, then rotation, then scale and then again translation to "offset" the camera.

However, in every book i read, there is one core principle to keep in mind when working with matrix translations, and that is the order of the application of transformations. And it is different: Scale, Rotation, Translate.

What am i not getting?

  • 3
    \$\begingroup\$ it works as expected, because it's doing the translation, then the rotation, then the scale. right order. The last translation is just to make the camera focus on the center of the screen, instead of the top left corner. \$\endgroup\$ May 6, 2012 at 18:08
  • \$\begingroup\$ @GustavoMaciel However when i look at this example toymaker.info/Games/XNA/html/xna_matrix.html it uses a different combinatoin, and that might be confusing. \$\endgroup\$
    – user8409
    May 7, 2012 at 7:32
  • 1
    \$\begingroup\$ Recommended order for XNA is SRT. \$\endgroup\$
    – 3Dave
    May 7, 2012 at 17:35
  • \$\begingroup\$ @DavidLively the source of the confusion might be exactly that, since you position an object via SRT, but positioning the 2D camera requires TRS, if you will \$\endgroup\$
    – user8409
    May 9, 2012 at 8:58
  • \$\begingroup\$ @UrbanEsc ah - you're right of course. View matrix vs world matrix. \$\endgroup\$
    – 3Dave
    May 9, 2012 at 16:04

2 Answers 2


Short Answer

SRT is the usual order for a world matrix. The camera uses a view matrix which works by taking the entire world and transforming it in the opposite direction from where the camera is located. Since this opperation is the opposite of a world matrix, the multiplication order needs to be reversed as well as its arguments.

Long Answer

The SRT order mentioned in the books is the correct order to create a transformation matrix to position an object in the world, or in other words, a world matrix.

Your 2D camera class on the other hand, is creating a view matrix which works almost in the opposite way. To be more specific, it moves the entire world in the opposite direction as the camera, giving the illusion that the camera is the new origin of the world.

So for instance, if you have a camera that's positioned at (50, 0) and rotated 45º to the right, the way to simulate that is to perform the inverse transformation on the world, i.e. translate everything in the world by (-50, 0) so that the camera becomes positioned at (0,0) and then rotate it 45º to the left to give the illusion that the camera is rotated to the right.

The conclusion is, since you're performing the inverse operation as a world matrix, the multiplication order needs to be reversed too.

With Pictures

Not sure if it helps, but I tried making a few pictures to demonstrate why order matters, and why there's a correct order (they didn't turn out too well though..).

First for world matrices. Imagine a square object located at (50,0), rotated 45 degrees to the left, and double its normal size. Since transformations are always relative to the origin the image below should make it clear why SRT gives the correct results, while TRS does not.

enter image description here

Now, as I explained earlier the view matrix works by doing the opposite of the world matrix. Look at the image below and imagine that the red square outline is the camera. The job of the view matrix is to transformeverything so that the camera is placed at the origin, while maintaining all the relative proportions and positions between the camera and the world. The example shown is the correct transformation order for a view matrix.

enter image description here

As you can see, TRS works in this case, and places the camera at the origin. Now if you try doing it SRT instead, while using the same parameters, the camera will end up far away from the origin which is not what we want.


After some poking around, i found an answer to a different question, that discusses various matrix operation orders and what they are used for. Though they lack explicit detail they are a good reference

Transformation order when dealing with Meshes


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .