meaning of m34 of CATransform3D

*爱你&永不变心* 提交于 2019-12-18 10:24:43

问题


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?


回答1:


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:

  • m34 = 1/z distance to projection plane (the 1/ez term in the reference link)
  • + for the z axis is towards the viewer, resulting in a "looking in the mirror" feel when using -
  • projection center is (0,0,0) plus any translations you set up



回答2:


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 resolutions is here:

Entities:

  • eye - distance from screen to eye
  • scale - visual scale of transformed object
  • distance - distance to transformed object

Connecting 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);
}


来源:https://stackoverflow.com/questions/3881446/meaning-of-m34-of-catransform3d

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