如何获取罗盘方向
我想在屏幕上显示手机面向的方向。例如:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这就是轴(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