Getting the 'scale' from a CATransform3D
I'm not familiar with the API but CATransform3D
looks like a regular 4x4 transformation matrix for doing 3D transformations.
Assuming that it represents nothing more than a combination of scale, rotation and translation, the scale factors can be extracted by calculating the magnitudes of either the rows or columns of the upper left 3x3 depending on whether CATransform3D
is row or column major respectively.
For example, if it is row-major, the scale in the x-direction is the square root of ( m11 * m11 ) + ( m12 * m12 ) + ( m13 * m13 ). The y and z scales would similarly be the magnitudes of the second and third rows.
From the documentation for CATransform3DMakeTranslation
it appears that CATransform3D
is indeed row-major.
To get the current scale of the layer you just perform a valueForKeyPath:
on the layer:
CGFloat currentScale = [[layer valueForKeyPath: @"transform.scale"] floatValue];
Other keys can be found in Apples Core Animation Programming Guide