How can I use the UIAccelerometer
class to compute the distance traveled by a person?
Asked
Active
Viewed 105 times
0
1 Answers
3
This is impractical, due to limitations with accelerometers.
- They measure acceleration, not distance. You can integrate it to get the velocity and integrate the velocity to get a distance, but the double integration will lose accuracy very fast, and even without the accuracy concerns, you need to establish an initial velocity, which the accelerometer can't work out.
- You also need high-frequency orientation data to distinguish between acceleration and gravity. Without this, you can't tell in which direction the velocity is increasing. You can't even tell if it is linear; someone could be spinning the device on the end of a string.
Use GPS instead, via the CLLocationManager
class.

Marcelo Cantos
- 181,030
- 38
- 327
- 365
-
In gees. An acceleration of `1` is approximately equal to the acceleration due to gravity at sea level (see [here](http://developer.apple.com/iphone/library/documentation/UIKit/Reference/UIAcceleration_Class/Reference/UIAcceleration.html#//apple_ref/doc/c_ref/UIAcceleration)). But why are you asking? You can't use acceleration. – Marcelo Cantos May 27 '10 at 11:17
-
When I say very fast, I mean that the reading would probably be severely degraded within seconds and completely meaningless within minutes; and this is without the problem of not having orientation data, which basically makes it impossible. – Marcelo Cantos May 27 '10 at 11:53
-
Just getting the acceleration accurate is difficult, take a look at [this question](http://stackoverflow.com/questions/2733249/detecting-acceleration-in-a-car-iphone-accelerometer) – progrmr May 27 '10 at 13:07