Since we need to consider all possible orientations
of the smart mobile device, we must adjust the compass
data accordingly. For example, assume that we
hold the device in portrait mode in front of us towards
the North. Then, the compass data we obtain indicate
that we are viewing in northern direction. As soon as
we rotate the device, however, the compass data will
change, although our view still goes to northern direction.
This is caused by the fact that the reference
point of the compass corresponds to the upper end of
the device. To cope with this issue, we must adjust
the compass data using the above presented rotation
calculation. When subtracting the rotation value (i.e.,
0 and 359) from the compass data, we obtain the
desired compass value, still viewing in northern direction
after rotating the device (cf. Fig. 5).
Figure 5: Adjusting the compass data to the device’s current
rotation.