What's the meaning of m34 of the structure CATransform3D, I only know it can change the perspective, but what's the meaning when the value is -0.001 and 0.001?
You can find the full details here. Note that Apple uses the reversed multiplication order for projection (relative to the given link) so all matrix multiplications are reversed and all matrices are transposed.
A short description of the meaning:
I read some articles including this one: https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/CoreAnimation_guide/AdvancedAnimationTricks/AdvancedAnimationTricks.html#//apple_ref/doc/uid/TP40004514-CH8-SW13
My solutions is here:
Entities:
eye
- distance from screen to eyescale
- visual scale of transformed objectdistance
- distance to transformed objectConnecting formulas:
scale = eye / (eye + distance)
distance = eye * (1.0/scale - scale)
eye = distance / (1.0/scale - scale)
Example of computing z-distance for desized scale of selected eye distance:
CATransform3D transformByScaleAndEye(CGFloat scale, CGFloat eye) {
CATransform3D t = CATransform3DIdentity;
t.m34 = -1.0 / eye;
CGFloat distance = -eye*(1.0/scale - scale);
return CATransform3DTranslate(t, 0, 0, distance);
}
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