在 Android 中使用磁场
所以我正在编写一个应用程序来查看设备是否旋转了 360 度。我这样做的方法是将加速度计传感器与磁场传感器结合使用。通过这个方法,我得到了 X、Y 和 Z 轴的三个值,但是如何使用这些值来计算北在哪里?
我已经做了一些测试:当我将其中一个轴指向北时,它的值大约变为 0.0,但是当我将其指向南时,它还会显示 0.0,并且当我将其指向东或西时,每个轴的值也会显示不同的值(对于X:大约-3.1东)
So I'm writing an application to see if the device has rotated 360 degrees. The way I do this is using the Accelerometer sensor combined with the Magnetic field sensor. From this method I get three values of the X, Y and Z axes, but how can I use these to calculate where North is?
I already did some testing: When I point one of the axes north, I the value of it turns approximately 0.0, but when I point it south, it also shows me 0.0 and different values per axe when I point it east or west (For X: somewhat around -3.1 east)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,我今天做了一些测试,我的解决方案对我有用,只需取 X 值即可。这对我有用,因为我只需相对使用它(比较两个值)。有关更多信息,请查看对我的问题的评论或查看此 文章。
Ok so I did some tests today and my solution worked for me, to just take the X value. This works for me because I only have to use it relatively (compare two values). For more information, look at the comment on my question or take look at this article.