One embodiment the invention includes a method of determining an
orientation of a sensor. The method includes measuring a local magnetic
field vector and a local gravity vector and using those measurements to
determine the orientation of the sensor. Embodiments can include
measuring the magnetic field vector and the local gravity vector using
quaternion coordinates. Another embodiment includes measuring a local
magnetic field vector, a local gravity vector, and the angular velocity
of the sensor. These three vectors are processed to determine the
orientation of the sensor. In one embodiment the three vectors can all be
measured in quaternion coordinates. Another method embodiment includes
determining a local gravity vector by providing a acceleration detector,
moving the detector from a start point to an end point over a time
period, and summing acceleration measurements over the time period. The
local gravity vector is calculated using the summed acceleration
measurements.