Could I get a basic explanation of CATransform3DIdentity?

倾然丶 夕夏残阳落幕 提交于 2019-12-19 02:34:06

问题


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?


回答1:


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:

Provided via 'internet wayback machine': http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CoreAnimation_guide/Articles/Layers.html

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!



来源:https://stackoverflow.com/questions/7128829/could-i-get-a-basic-explanation-of-catransform3didentity

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!