从加速度计找到手机的角度?

发布于 2024-10-14 06:30:44 字数 89 浏览 8 评论 0原文

我正在尝试制作一个充当六分仪的应用程序(以查找物体的高度)。是否可以使用加速度计的数据来查找手机指向的角度?理想情况下,用户将手机横向放置,并沿着手机边缘看向角度。

I am trying to make an application that will act as a sextant (to find the height of an object). Is it possible to use the data from the accelerometer to find the angle the phone is pointing? Ideally, the user will hold their phone in the landscape position and look along the edge of it to sight the angle.

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

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

发布评论

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

评论(4

‖放下 2024-10-21 06:30:44

只能使用加速度计来使用您的移动设备充当六分仪。

要查找结构的高度,请按照以下步骤操作:

  • 用户握住手机并沿着手机边缘查看结构的底部
    在这里,他按下了 ButtonA。

  • 用户握住手机并沿着手机边缘看向结构的顶部
    在这里,他按下了 ButtonB。

您的应用程序需要在按下按钮时保存 accel z 值。

现在可以将角度计算为:

Theta = (Zb/Za) 的反余弦

You CAN use ONLY accelerometer to use you mobile device to act as a sextant.

To find height of a structure follow this procedure:

  • The user holds the phone and looks along the edge of it to bottom of the structure.
    Here he presses ButtonA.

  • The user holds the phone and looks along the edge of it to top of the structure.
    Here he presses ButtonB.

Your app needs to save the accel z value when the buttons are pressed.

The angle can now be calculated as:

Theta = inverse-cosine-of (Zb/Za)

-残月青衣踏尘吟 2024-10-21 06:30:44

加速度计数据可以告诉您重力的拉动方向,并据此您可以计算出手机相对于地面的握持角度。它不太可能非常稳定或准确,因此我不确定它对于您所描述的精确用途的效果如何。

http://code.google.com/p/moonblink/wiki/Tricorder
这个应用程序基本上是手机可以为您提供的加速度计数据和指南针数据的精彩演示。我建议您看一下传感器提供的数据是否对您的想法有用。

The accelerometer data can tell you what direction gravity is pulling and from that you can figure out what angle the phone is being held at with respect to the ground. It's not likely to be very stable or accurate so I'm not sure how well it will work for a precise use like what you are describing.

http://code.google.com/p/moonblink/wiki/Tricorder
This app is basically a great demo of both the accelerometer data and the compass data your phone can give you. I recommend taking a look at it to see if the data the sensors give you can be of any use for your idea.

我不是你的备胎 2024-10-21 06:30:44

使用方向传感器。请参阅 SensorManager 文档

如果您还没有见过,有一个名为 Surveyor 的应用程序,它的功能与您所追求的类似。

Use the orientation sensor. See the SensorManager documentation.

If you haven't seen it, there's an app out called Surveyor that does something similar to what you're after.

清风疏影 2024-10-21 06:30:44

我认为这是不可能的。手机会给你的唯一数据是加速度,即速度随时间的变化。

您需要的是一部具有此处所述的指南针功能的手机。我认为使用这个传感器你将能够实现一个类似六分仪的应用程序。

I don't think this is possible. The only data the phone will give you is the acceleration, the change in speed over time.

What you need is a phone with a compass feature described here. I think using this sensor you would be able to implements a sextant like app.

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