O'Reilly logo

Beginning iOS 5 Application Development by Wei-Meng Lee

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

USING THE GYROSCOPE AND ACCELEROMETER

The gyroscope in an iOS device enables you to measure the device's angular acceleration around the x, y, and z axes. Figure 15-1 shows how this enables you to accurately measure the yaw, pitch, and roll of the device.

The accelerometer in iOS devices measures the acceleration of the device relative to freefall. A value of 1 indicates that the device is experiencing 1 g of force exerted on it (1 g of force being the gravitational pull of the earth, which your device experiences when it is stationary). The accelerometer measures the acceleration of the device in three different axes: x, y, and z. Figure 15-2 shows the different axes measured by the accelerometer.

image

FIGURE 15-2

Table 15-1 shows example readings of the three axes when the device is in the various positions. Bear in mind that you won't see the exact same values as these, because they are always fluctuating due to the accelerometer's sensitivity.

TABLE 15-1: Example Readings of the X, Y, and Z Axes

image

image

If the iPhone is held upright and moved to the right quickly, the value of the x-axis will increase from 0 to a positive value. If it is moved to the left quickly, the value of the x-axis will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required