开发者

UI Accelerometer reference to compute the distance traveled by a person

开发者 https://www.devze.com 2023-01-01 01:19 出处:网络
How can I use the UIAccelerometer class to compute th开发者_JAVA百科e distance traveled by a person?This is impractical, due to limitations with accelerometers.

How can I use the UIAccelerometer class to compute th开发者_JAVA百科e distance traveled by a person?


This is impractical, due to limitations with accelerometers.

  1. 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.
  2. 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.

0

精彩评论

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

关注公众号