通过加速度计算方向
目前,我正在尝试在Android手机上结合加速度计和陀螺仪来计算手机的方向(每个轴旋转多少角度)。我知道加速度不能简单地计算手机的确切方向,但它可以计算方向的“稳态”,然后陀螺仪可以监视方向的变化。但我却卡在了第一步。有谁知道如何使用加速度数据来获得大致方向?有没有计算各轴旋转角度的公式?
Currently, I am trying to combine accelerometer and gyroscope on android phone to calculate the orientation (how much angle each axis rotates) of the phone. I know that acceleration cannot simply calculate the exact orientation of the phone but it could calculate a "steady state" of orientation and then gyroscope could monitor the change of orientation. But I am stuck at the first step. Does anybody know how to use acceleration data to get the approximate orientation? Is there any formula to calculate the angle rotated by each axis?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
听起来您需要将重力矢量转换为极坐标,将其反转以使其表示“向上”,然后对角度求反以使其表示手机相对于垂直方向的偏移,而不是垂直于手机的偏移。
第一步如下所述:http://en.wikipedia.org/wiki/Spherical_coefficient_system#Cartesian_cooperatives
对于其余部分,我认为 θ' = π - θ 和 φ' = π - φ 有效。
It sounds like you need to convert the gravity vector to polar coordinates, invert it so that it represents 'up', and then negate the angles so that it represents the offset of the phone from vertical rather than the offset of vertical from the phone.
Step one is described here: http://en.wikipedia.org/wiki/Spherical_coordinate_system#Cartesian_coordinates
For the rest I think θ' = π - Θ and φ' = π - φ works.