iphone sdk CGAffineTransform 获取对象的旋转角度 [英] iphone sdk CGAffineTransform getting the angle of rotation of an object

查看:23
本文介绍了iphone sdk CGAffineTransform 获取对象的旋转角度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何计算任何给定对象(即 uiimageview)的旋转角度?

how do i calculate the angle of rotation for any given object (ie a uiimageview)?

推荐答案

从技术上讲你不能,因为变换可以包括一个 skew 操作,将图像变成平行四边形,并且旋转角度是'不再定义.

Technically you can't, because the transform can include a skew operation which turns the image into a parallelogram and the rotation angle isn't defined anymore.

无论如何,由于旋转矩阵生成

Anyway, since the rotation matrix generates

 cos(x)  sin(x)   0
-sin(x)  cos(x)   0
   0        0     1

你可以用

return atan2(transform.b, transform.a);

这篇关于iphone sdk CGAffineTransform 获取对象的旋转角度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆