tags:

views:

131

answers:

4

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 using an iPhone application. You'd start the application, press a button to start measurement at the bottom of a box, move your iPhone from to the top of the box, then press a button to stop measurement. The application would then calculate and display the height of the box.

How would I use the accelerometer to perform this kind of measurement?

+1  A: 

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 )
mkoistinen
+2  A: 

Try photographing an object of a known size at the distance of interest.

hotpaw2
+1  A: 

Depending on the application, and how much accuracy you need, you may be able to use the new 6-axis gyro accelerometers in the iPhone 4 and iPod Touch 4th Gen. You could get the total displacement by integrating the acceleration vector.

When integrating acceleration to get displacement, any errors will be cumulative, so this may not be appropriate, but may be worth considering.

Nick Forge
A: 

GPS is currently not accurate enough to measure a box. Take into account that there may be an error of about 10 meters to a mile. You can get back the accuracy of the measure with CLLocation.

dkk
(at least for the iPhone GPS, differential GPS is another story)
dkk