title: Confused about order of operation when using a Matrix in XNA, C#
body: <p>Here are two different pieces of code</p>
  
  <p>This is what I started with</p>
  
  <pre><code>Vector2 hold = Vector2.Transform(pos1, mat1);
  Matrix inv = Matrix.Invert(mat2);
  Vector2 pos2 = Vector2.Transform(hold, inv);
  </code></pre>
  
  <p>And this is what i'm told is the simplified version</p>
  
  <pre><code>Matrix matrix1to2 = mat1 * Matrix.Invert(mat2);
  Vector2 pos2 = Vector2.Transform(pos1, matrix1to2);
  </code></pre>
  
  <p>What I don't understand is, why isn't the first line in the simpilifed version</p>
  
  <pre><code>Matrix matrix1to2 = Matrix.Invert(mat2)*mat1;
  </code></pre>
  
  <p>Since in matrix order the thing on the right would take effect first and in the original we have mat1 being multiplied in first</p>
  
  <p><strong>Edit:</strong>
  The following image shows the order of operations desired</p>
  
  <p><a href="http://www.riemers.net/images/Tutorials/XNA/Csharp/Series2D/mat1.png" rel="nofollow">http://www.riemers.net/images/Tutorials/XNA/Csharp/Series2D/mat1.png</a></p>
  
  <p>The tutorial says that to create this transformation you use;</p>
  
  <pre><code>Matrix carriageMat = Matrix.CreateTranslation(0, -carriage.Height, 0) * Matrix.CreateScale(playerScaling) 
  * Matrix.CreateTranslation(xPos, yPos, 0) * Matrix.Identity;
  </code></pre>
  
  <p>Why does this work if the order is left to right?</p>