如何获取罗盘方向

发布于 2024-09-25 04:15:29 字数 593 浏览 6 评论 0原文

我想在屏幕上显示手机面向的方向。例如:

   0
   |- []
   |_
  South --- North

在上图中,手机将显示“北”。由于用户(头部带有 0 的棍子)将手机(图中的 [])指向北方。

我发现这个示例。我明白它在做什么,除了它似乎在计算偏航、俯仰、滚动和倾斜。这些是什么以及如何使用它们来简单地找到手机指向的方向?

还有这个 android 文档 提到 X、Y 和 Z 轴,但我没有看到任何地方说明这些轴如何与手机相对应? Z是从手机底部到顶部吗?

I want to show the direction on the screen that phone is facing. For example:

   0
   |- []
   |_
  South --- North

In the above diagram the phone would display "North". Since the user (the stick with 0 for his head) is holding out the phone (the [] in the diagram) pointing north.

I found this example. I understand what it's doing except it seems to calculate yaw, pitch, roll, and inclination. What are those and how would I use them to simply find which way the phone is pointing?

Also this android documentation mentions X, Y, and Z axises but I don't see anywhere that says how those axises correspond to the phone? Is Z going from the bottom of the phone to the top?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

↙温凉少女 2024-10-02 04:15:29

就是轴(axiy?)的样子。

我找不到我使用的备忘单的链接,但它看起来有点像 这个

总之,您想要注册以监听 Sensor.TYPE_ORIENTATION,从传入的值数组获取 value[0],这应该会显示您的角度(我相信是从北)。

一些示例来自 *android.com

this is how the axis (axiy?) look like.

I couldn't find a link to the cheat sheet I use, but it looked sort of like this.

In summary, you want to register to listen for Sensor.TYPE_ORIENTATION, from the incoming array of values get, value[0] and that should show you your angle (from North I believe).

some example from *android.com

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