programming forums Java Java JSRs Mobile Certification Databases Caching Books Engineering Languages Frameworks Products This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
Sheriffs:
Saloon Keepers:
Bartenders:

# Does order of concatenation affect AffineTransforms?

Chris Crawford
Ranch Hand
Posts: 116
1
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: 1950
66
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.