在 Android 中使用磁场

发布于 2024-12-13 04:19:54 字数 211 浏览 4 评论 0原文

所以我正在编写一个应用程序来查看设备是否旋转了 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 技术交流群。

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

故事与诗 2024-12-20 04:19:54

好吧,我今天做了一些测试,我的解决方案对我有用,只需取 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文