Chapter 37
Introduction to Core Motion
Motion sensing has proven to be an effective input technique in applications, particularly games. All iOS devices have had the capability to detect motion, and most achieve this using an accelerometer. Starting with iPhone 4 and iPad 2, Apple has included a gyroscope in addition to the standard accelerometer found in its predecessors.
As far as developing motion-aware applications, accelerometer events have traditionally been available to applications through the UIAccelerometer class. Starting with iOS4, Apple has provided a new framework called Core Motion that exposes the functionality of both the accelerometer and the gyroscope (when available).
Accelerometers and Gyroscopes
An accelerometer is a device that measures acceleration along three axes (Figure 37-1). The standard unit of acceleration is “g”(short for gravity). 1g is the force pulling down on an object that is at rest at sea level.
The only time an accelerometer will give a reading of 0g is when the device is in free fall (not recommended). Depending on how your iPhone is placed, the 1g of acceleration can be distributed differently across the three axes. An accelerometer can measure both translational acceleration and tilt ...
Get iPhone and iPad App 24-Hour Trainer 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.