I am slowly getting more serious about Core Animation and would greatly appreciate an explanation composed of short words spoken (typed?) slowly explaining CATransform3DIdentity and why the following code does what it does (flips the layer around in '3D' space)
kFaceUpTransform = kFaceDownTransform = CATransform3DIdentity;
// Construct a 180-degree rotation matrix:
kFaceDownTransform.m11 = kFaceDownTransform.m33 = -1;
On second thought, type quickly and use multisyllabic words to your hearts content but please be gentle.
PS. I get the impression that I should become much more comfortable with linear algebra if I am to get much further with Animation...is this correct?
CATransform3DIdentity is an Identity matrix:
http://en.wikipedia.org/wiki/Identity_matrix
Basically, Matrices in animation mathematics are used to transform an object (skew, move, rotate etc).
An Identity matrix is one that when applied to an object, it resets it to its initial geography.
ex.
[1 0 0]
[0 1 0]
[0 0 1]
It's not easy to explain (I really don't understand properly myself in fairness) but these 3x3 matrices use the grid location (m11, m33) to determine how to transform the object, in this case m11 is is making it rotate 180 degrees, set it to +1 and it'd rotate the other direction. Set it to 0.5 and it'd rotate 90 degrees (iirc!).
ex.
[m11, m12, m13]
[m21, m22, m23]
[m31, m32, m33]
It's a bit scary but the pictures here kind of help:
http://en.wikipedia.org/wiki/Matrix_(mathematics)#Linear_transformations
and here
http://en.wikipedia.org/wiki/Transformation_matrix
Finally, the table at the bottom this this list show how the different fields of a matrix are used:
Apple Core Animation Programming Guide - Core Animation Basics
Finally, I recall reading this a while ago, it might be of some help as I think my explanations above aren't that handy - I'm telling you what, not why - and believe me, you need to know why to get into this kind of programming properly:
http://chortle.ccsu.edu/vectorlessons/vectorIndex.html
Best of luck!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With