Game Development Reference
In-Depth Information
The difference between these sensors really lies in the provided data. Both the ac-
celerometer- and gyro-provided velocities are for each axis, so essentially when the
device stops moving, the readings return to the idle values of the gravity vector for
the accelerometer, or zero for the gyro. You need to put in the effort to track these
sensors and update other values to get extra meaningful information out of them in
most cases.
The compass does something different. Just like a physical compass, the one
provided by the operating system provides values that indicate the rotation of the
device, rather than a velocity that can settle. Inside the CompassReading class
there are three values, the timestamp and two heading values that represent the
heading relative to the Magnetic North and the geographic True North.
We have two values for a reason. The Magnetic North reading provides the direc-
tion to the Magnetic North pole of the Earth, which isn't quite the same as the North
that you see on the maps. These instead use something called True North , or Geo-
graphic North , which represents the North Pole that the Earth rotates around. Both
values are provided as double data type representing the degrees from their re-
spective North poles (also known as bearing).
One thing to remember is that, just like a physical compass, the magnetometer can
be affected by magnetic fields, such as those generated by speakers. If the compass
is in an area of interference, we may get incorrect values from the device. Having
some form of backup control in case the compass is unreliable (that the users can
enable or disable) will help improve their experience.
Inclinometer
An inclinometer provides the yaw, pitch, and roll of the device in degrees, which is
quite useful because it provides usable data without having to worry about calcu-
lating these values based on readings from the accelerometer, gyro, and compass.
You'll see why not having this sensor isn't a big deal later on; however, if it is avail-
able you can get reasonably accurate readings easily, without having to go through
any extra effort.
To get started using the inclinometer, you'll be doing most of the same work as
the sensors that were mentioned earlier. Setup is done using the Inclinomet-
er::GetDefault() method, and you will need to set the ReportInterval to
Search WWH ::




Custom Search