Animation for catransform3d

Source: Internet
Author: User

The two attributes of the layer specify the transformation matrix: transform.
And sublayertransform
Attribute.

Layer Transform
Attribute of the specified Matrix
Anchorpoint
Properties apply to layers and layers.

Layer sublayertransform
The matrix specified by the attribute only affects the child layers of the layer, but not the layer itself.

You can change it in any of the following ways:
Catransform3d
Data structure:
Use the catransform3d Function
Directly modify the data structure member
Use Key-value encoding to change the Key Path

Catransform3didentity
Is the unit matrix, which has no scaling, rotation, skew, and perspective. Apply the Matrix to the layer, and change the geometric attribute of the layer to the default value.

You can use the transform function to operate the matrix in the core animation. You can use these functions (as shown in the following table) to create a matrix, which is usually used to change the layer or its child layers.
Transform
And sublayertransform attributes. Transform functions or directly operate or return a Data Structure of catransform3d. This allows you to build simple or complex conversions for reuse.

  • CATransform3DMakeTranslation
  • CATransform3DMakeScale
  • CATransform3DMakeRotation
  • CATransform3DTranslate
  • CATransform3DScale
  • CATransform3DRotate

Catransform3d transform function for moving, rotating, and scaling

Functions and usage

Catransform3dmaketranslation
Returns the transform of moving '(TX, Ty, TX. T' = [1 0 0 0; 0 1 0 0; 0 0 1 0; TX ty TZ 1].

Catransform3dtranslate
Translate 't'( Tx, Ty, Tz) 'and return the result: * t' = translate (TX, Ty, Tz) * t.

Catransform3dmakescale
Returns the transform of '( Sx, Sy, SX. : * T' = [SX 0 0 0; 0 Sy 0 0; 0 0 SZ 0; 0 0 0 1].

Catransform3dscale
Scale 'T' (sx, Sy, SZ) 'and return the result: * t' = Scale (sx, Sy, SZ) * t.

Catransform3dmakerotation
Returns the transformation of degrees in the radians of the vector '(x, y, z. Returns the unit matrix if the vector length is 0.

Catransform3drotate
Rotate 'T' in the angle of the Radian of vector '(x, y, z)' and return the result. t' = rotation (angle, x, y, z) * t.


The rotation angle is in radians rather than degrees. The following functions allow conversion between radians and degrees.

Cgfloat degreestoradians (cgfloat degrees) {return degrees * m_pi/180 ;};

Cgfloat radianstodegrees (cgfloat radians) {return radians * 180/m_pi ;};

1. Significance of catransform3d structure members.
Struct catransform3d
{
Cgfloat M11 (x scaling), M12 (Y shear), M13 (rotation), m14 ();
Cgfloat m21 (x shear), m22 (Y scaling), M23 (), M24 ();
Cgfloat m31 (rotation), M32 (), M33 (), m34 (perspective effect, the object to be operated must have a rotation angle, otherwise there is no effect. Integrity/Negative values make sense );
Cgfloat M41 (X translation), M42 (Y translation), m43 (Z translation), m44 ();
};
PS: when the overall ratio is changed, that is, when M11 = m22, if M33> 1, the overall image is reduced. If 0 <M33 <1, the overall image is enlarged. If S is <0, A symmetric proportional transformation is performed on the origin.

() Fill in the blank space.

See http://kirenenko-tw.blogspot.com/2012/12/core-animation_11.html

Code: https://github.com/robin2013/CATransform3D_Study.git

The code references

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.