rav*_*nsp 10 iphone core-animation catransform3d
如何通过提供CATransform3D结构作为输入来计算Z轴周围的旋转?
基本上我需要的是另一种方式CATransform3DMakeRotation.
Nad*_*ker 26
这取决于您正在进行旋转的轴.
围绕z轴的旋转表示为:
a = angle in radians
x' = x*cos.a - y*sin.a
y' = x*sin.a + y*cos.a
z' = z
( cos.a sin.a 0 0)
(-sin.a cos.a 0 0)
( 0 0 1 0)
( 0 0 0 1)
Run Code Online (Sandbox Code Playgroud)
所以角度应该是a = atan2(transform.m12,transform.m11);
围绕x轴旋转:
a = angle in radians
y' = y*cos.a - z*sin.a
z' = y*sin.a + z*cos.a
x' = x
(1 0 0 0)
(0 cos.a sin.a 0)
(0 -sin.a cos.a 0)
(0 0 0 1)
Run Code Online (Sandbox Code Playgroud)
围绕y轴旋转:
a = angle in radians
z' = z*cos.a - x*sin.a
x' = z*sin.a + x*cos.a
y' = y
(cos.a 0 -sin.a 0)
(0 1 0 0)
(sin.a 0 cos.a 0)
(0 0 0 1)
Run Code Online (Sandbox Code Playgroud)
sch*_*sch 17
如果转换附加到图层,则可以获得如下的旋转值:
CGFloat angle = [(NSNumber *)[layer valueForKeyPath:@"transform.rotation.z"] floatValue];
Run Code Online (Sandbox Code Playgroud)
从文档:
Core Animation扩展了键值编码协议,允许通过关键路径获取和设置图层CATransform3D矩阵的公共值.表4描述了层的转换和sublayerTransform属性是键值编码和遵守观察的关键路径
| 归档时间: |
|
| 查看次数: |
5992 次 |
| 最近记录: |