计算角度 - android
我一直在试图解决这个问题,但没有运气。
我想计算当围绕 z 轴旋转手机时手机的方向和 y 轴之间的角度。我将手机放在面前,将其从纵向倾斜到横向,y 轴穿过地球中心。现在我想要倾斜的角度。我制作了一张图片来解释我需要什么角度,但我需要更多的声誉来发布图像......
现在我想知道要使用什么传感器类型以及哪个值。在我的尝试中,我无法分离出那个特定的角度。我得到的最接近的是带有 value[2] 的 TYPE_ROTATION_VECTOR,但我没有让它完全工作,此外,你需要 api level 9 才能实现这一点。
I've been trying to figure this out, but with no luck.
I want to calculate the angle between the phone's orientation and the y-axis, when rotating the phone around the z-axis. I'm holding the phone in front of me and tilting it from portrait orientation towards landscape landscape orientation, with the y-axis running through the center of the earth. Now I want the angle of the tilt. I had made a picture explaining what angle I need, but I needed more reputation to post images...
Now I want to know what sensor type to use and which value. In my tries I haven't been able to isolate just that specific angle. The closest one I got was TYPE_ROTATION_VECTOR with value[2] but I didn't get that to work fully, and besides, you needed api level 9 for that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你需要的是 SensorManager.getOrientation()
What you need is SensorManager.getOrientation()