views:

855

answers:

2

I think that there are some issues with the earth Gravity, so I wonder if there are any examples where the accelerometers work by subtracting these.

+3  A: 

(It's too bad you can't file a bug with planet Earth to fix its Gravity issue!)

There are several examples listed under "Related sample code" in the UIAcceleration Class Reference.

As that doc states, a value of 1.0 represents roughly +1g. So if you point the iPhone straight up in portrait orientation, you should see roughly <0, -1, 0>. As you rotate the phone around, the magnitude of the acceleration vector sqrt(x*x+y*y+z*z) should stay around 1.

Daniel Dickison
+2  A: 

Apple's AccelerometerGraph demo includes sample code that implements a high-pass filter-- effectively filtering out the effect of gravity. It's pretty simple to just grab it and modify to suit your needs.

Tom Harrington
Thnaks for the hint!
Thanks