如何检测android设备平行于地面的旋转? [英] How to detect android device rotation parallel to the ground?
问题描述
据我所知,大多数android设备都允许通过加速度计检测旋转,但是我注意到,它无法检测到平行于地面的旋转.例如,如果我将设备放在桌子上并旋转,则加速度计指示器中的任何一个都不会改变.
As I know, the most of android devices allows to detect rotation by accelerometer, but I've noticed, that it doesn't detect rotation parallel to the ground. For example, if I put the device on a table and turn it around, no one of accelerometer indicators doesn't change.
在图片上,这称为阿尔法"旋转.那么我怎么能检测到这种转弯呢?
At the picture, it's called "alfa" rotation. So how can I detect this kind of turning?
推荐答案
要感知绕z轴的旋转,您需要实现一个指南针功能.不错的教程是此.为了使结果值更稳定,您需要实施一些算法,以平滑您的传入数据(对数据队列的平均值,过滤异常值等).这是一个很好的概述.
For sensing rotation around z-axis you need to implement a compass function. A good tutorial is this one. To make the resulting values more stable you need to implement some algorithm which smoothes your incoming data (averages over a queue of data, filtering outliers, etc.). Here is a good overview.
这篇关于如何检测android设备平行于地面的旋转?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!