开发者

Find angle of phone from the accelerometer?

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 alo开发者_StackOverflow社区ng the edge of it to sight the angle.


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)


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.


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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜