Reputation:
While using playground I discovered somewhat of an unexpected scenario
I was translating a square(w: 100, h: 100)
from (0,0)
to (150, 150)
and rotating it .pi. I was using concatenation to translate and rotate the square at the same time, so this came as a surprise but when I switched what order I was calling the translation and rotation, the square would move different ways
When I rotated the square before I translated it, the square would move from(0,0)
to (150, 150)
, as predicted
However, when I translated before I rotated the square, the square would move from (0,0)
and rotate up and left off the screen, which to me doesn't logically make sense, can someone try and explain this to me?
Upvotes: 0
Views: 226
Reputation: 535850
Because of the nature of matrix algebra, the order in which transforms are applied in concatenating
(aka CGAffineTransformConcat
) is the opposite of the order in which you would apply them one by one to get the same effect.
Upvotes: 1