How do I measure the distance traveled by an iPhone using the accelerometer?

后端 未结 5 1334
渐次进展
渐次进展 2020-12-13 11:33

While GPS works for long distance changes, I would like to measure a shorter distance by using the iPhone\'s accelerometer.

Say I want to measure a height of a box u

5条回答
  •  遥遥无期
    2020-12-13 12:16

    Pythagorean Theorem: c^2 = a^2 + b^2 (http://en.wikipedia.org/wiki/Pythagorean_theorem)

    In your case, if point A = (Ax, Ay) and B = (Bx, By), then you can compute the distance C by:

    C = sqrt( (Bx-Ax)^2 + (By-Ay)^2 )
    

提交回复
热议问题