# Does order of concatenation affect AffineTransforms?

Chris Crawford
Ranch Hand
Posts: 96
I'm working with AffineTransforms, and am confused by one aspect of their behavior. It appears that the order in which two sequential concatenations are executed effects the final result. Here's a fragment of code to illustrate the concept:

This code has dramatically different results if the two concatenations are reversed in order. I'm not asking anybody to fix my code; I want to understand what's going on. Is it really true that the order of concatenations affects the final result? From my understanding of matrix multiplication, it shouldn't. Have I missed something here?

Piet Souris
Rancher
Posts: 1402
29
hi Chris,

yes, the order DOES matter.

Each AffineTransformation is internally represented by a 3 x 3 matrix.
If you have two of them, say R and T, then the resulting matrix is
obtained by applying a matrix multiplication.

So, if your order is: R, then T, then the result is the matrix R * T.
If the order is: first T, then R, then the resulting matrix is T * R.

In general, matrix multiplications are not commutative, i.e:

R * T <> T * R.