Orientation and Scale of Acceleration

The device’s acceleration is measured in Gs. 1G is the force due to the earth’s gravity. (When the device is still, the accelerometer doesn’t know if it is moving at a constant velocity in the earth’s gravity well or if it is far out in space and accelerating upwards at 9.8 meters per second every second.)

While the application is running, hold the device vertically in front of your face as if you were using it. Check the console: the y-component of the acceleration is approximately -1, and the x- and z-components are approximately 0. If you lay the device on its back, the z-component of the acceleration is approximately -1, and the others are approximately 0. If you balance the device on the edge with the ...

Get iOS Programming: The Big Nerd Ranch Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.