core animation - Why does order of transforms matter in Xcode? -


these 2 sequences give 2 different results in image layer transform applied to. don't seem reason why... can give explanation this?

/* first sequence of transformation */ cgaffinetransform transform = cgaffinetransformidentity; transform = cgaffinetransformrotate(transform, m_pi / 180 * 30); transform = cgaffinetransformtranslate(transform, 100, 0);  /* second sequence of transformation */ cgaffinetransform transform = cgaffinetransformidentity; transform = cgaffinetransformtranslate(transform, 100, 0); transform = cgaffinetransformrotate(transform, m_pi / 180 * 30); 

short (technical) answer: because transform matrix , when concatenate 2 transforms, 2 matrices multiplied. matrix multiplication isn't commutative, meaning 𝐀⨉𝐁 (ab) not same 𝐁⨉𝐀 (ba). in other words, order matters.

i have written combining translations , rotations , the math behind transforms (i.e. matrix mathematics). these 2 can resources if want learn more how transforms work.

there nice project richard turton on github experimenting transforms can useful grasping concepts of how order of different transforms impact end result.


Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -