计算旋转图像的当前角度 Iphone 与 Android

发布于 2025-01-05 19:36:19 字数 679 浏览 3 评论 0原文

在 iOS 中查找图像轮的当前角度。

- (float) currentAngle
   {

float angle = radiansToDegrees(atan2(wheeler.transform.b, wheeler.transform.a)) + 1;    
if(angle < 0) {
    angle = 360 + angle;
}
return angle;
    }

Android 是否有具有transform.a 和transform.b 属性的等效transform 对象?现在,我使用这段代码来执行图像对象在其自身轴上的旋转。但我需要定期找出它的当前位置或角度。

   RotateAnimation anim = new RotateAnimation(0f, 360,  Animation.RELATIVE_TO_SELF,    0.5f, Animation.RELATIVE_TO_SELF,
             0.5f);

     anim.setInterpolator(new LinearInterpolator());
     anim.setRepeatCount(Animation.INFINITE);
     anim.setDuration(1900);
     imageView.startAnimation(anim);

To find the current angle of the image wheeler in iOS.

- (float) currentAngle
   {

float angle = radiansToDegrees(atan2(wheeler.transform.b, wheeler.transform.a)) + 1;    
if(angle < 0) {
    angle = 360 + angle;
}
return angle;
    }

Does Android have the equivalent tranform object that has the property of transform.a and transform.b ? Right now I am this code to perform the rotation of a image object in its own axis. but I need find out its current position or angle periodically.

   RotateAnimation anim = new RotateAnimation(0f, 360,  Animation.RELATIVE_TO_SELF,    0.5f, Animation.RELATIVE_TO_SELF,
             0.5f);

     anim.setInterpolator(new LinearInterpolator());
     anim.setRepeatCount(Animation.INFINITE);
     anim.setDuration(1900);
     imageView.startAnimation(anim);

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文