Game Development Reference
In-Depth Information
Think about holding the device vertically. If you rotate the device about the axis de‐
scribed by the gravity vector, none of the accelerometers will measure any change in the
force acting on their test masses. We can't measure that degree of freedom. To do so,
we'd need to fix a gyroscope to the device, and even these run into problems when a
body is free to rotate about all three axes. See Chapter 11 for a discussion on Euler angles.
Now let's discuss what we can accomplish. First, Figure 21-4 demonstrates the coordi‐
nate system we'll use; the actual coordinate system used will be determined by the man‐
ufacturer of your device, so make sure to check its documentation.
Figure 21-4. Accelerometer coordinate system
Now if we make some assumptions based on how a user will hold our device, we can
determine some “gross” orientations. For illustration, Table 21-2 gives some idea of what
each value would be for each gross direction, assuming the coordinate system shown
in Figure 21-4 .
Table 21-2. Gross acceleration values and orientations
Device orientation
X
Y
Z
Face down on table
0
0
1
Face up on table
0
0
−1
Horizontal on table, right side down
1
0
0
Horizontal on table, left side down
−1
0
0
Vertical on table, bottom down
0
−1
0
Vertical on table, top down
0
1
0
There are a few things to note here. First, if you were to hold the phone in these orien‐
tations with your hand, the accelerometer is sensitive enough to pick up small deviations
 
Search Nedrilad ::




Custom Search