문제

How can I use the UIAccelerometer class to compute the 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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top