If you want to keep a fixed origin when stretching your CALayer, you can change its anchorPoint property as follows:
layer.anchorPoint = CGPointMake(0.0f, 0.0f);
anchorPoint defines the point at which transformations apply to your layer. It is also tied to your position layer, so if you edit anchorPoint , you may need to change the layer again.
Having set the anchor point, you should set your layer with the coordinate of the source origin and stretch it using your transform. However, you will not maintain the integral width and height.
As for the elements of m12 , etc. CATransform3D, this structure is a 4x4 matrix:
struct CATransform3D { CGFloat m11, m12, m13, m14; CGFloat m21, m22, m23, m24; CGFloat m31, m32, m33, m34; CGFloat m41, m42, m43, m44; }; typedef struct CATransform3D CATransform3D;
where each value represents one location in the matrix. This matrix is ββbased on 3D OpenGL matrices, such as a model representation matrix. Core Animation provides helper functions for most of the manipulations with this matrix that you will need, but from time to time you will set one of the matrix elements (for example, m34 for the perspective effect).
I have never been good at math, but you can find any of the comments that people put together for math for OpenGL display mockups and apply it here.