ios – 关于CGAffineTransformMakeRotation旋转方向?

ios – 关于CGAffineTransformMakeRotation旋转方向?,第1张

概述我正在尝试使用CGAffineTransformMakeRotation,我引用的是Apple文档 The angle, in radians, by which this matrix rotates the coordinate system axes. In iOS, a positive value specifies counterclockwise rotation and a neg 我正在尝试使用CGAffinetransformMakeRotation,我引用的是Apple文档

The angle,in radians,by which this matrix rotates the coordinate system axes. In iOS,a positive value specifIEs counterclockwise rotation and a negative value specifIEs clockwise rotation. In OS X,a positive value specifIEs clockwise rotation and a negative value specifIEs counterclockwise rotation.

所以,我通过参数90度,它应该逆时针旋转.
self.myVIEw是灰色背景颜色视图,红色正方形视图仅用于查看旋转方向

#define degrees_TO_radians(x) (x * M_PI/180.0)CGAffinetransform rotation = CGAffinetransformMakeRotation( degrees_TO_radians(90) );[self.myVIEw settransform:rotation];

但为什么顺时针旋转?
我正在尝试使用模拟器和设备都有相同的结果,顺时针旋转
然后跟踪使用动画:

#define degrees_TO_radians(x) (x * M_PI/180.0)CGAffinetransform rotation = CGAffinetransformMakeRotation( degrees_TO_radians(90) );[UIVIEw animateWithDuration:0.5                 animations:^{                     self.myVIEw.transform = rotation;                 }                 completion:^(BOol finished) {                     NSLog(@"%@",NsstringFromCGAffinetransform(self.myVIEw.transform));                 }];

它具有相同的结果,顺时针旋转.

有人可以解释为什么,谢谢你的回复.

解决方法 这是文档中的错误.

他们描述矩阵并提供他们用来进行变换的方程:

如果你做数学,你会看到正角度,当Y轴方向向上是向上旋转时逆时针旋转,如在OS X中,当Y轴向下指向时,顺时针方向如在iOS中

例如,您可以尝试将点(5,0)转换为90度,您将获得(0,5),这意味着iOS的顺时针方向和OS X的逆时针.

相同的文件仍然有你引用的(false)部分:

In iOS,a positive value specifIEs counterclockwise
rotation and a negative value specifIEs clockwise rotation. In OS X,a
positive value specifIEs clockwise rotation and a negative value
specifIEs counterclockwise rotation.

这显然是错误的,因为方程(这是相同的文件的一部分,而且是standard rotation equations)表示相反.

总结

以上是内存溢出为你收集整理的ios – 关于CGAffineTransformMakeRotation旋转方向?全部内容,希望文章能够帮你解决ios – 关于CGAffineTransformMakeRotation旋转方向?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1113208.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存