Index: spec-source-orientation.html =================================================================== RCS file: /sources/public/geo/api/spec-source-orientation.html,v retrieving revision 1.42 diff -u -r1.42 spec-source-orientation.html --- spec-source-orientation.html 7 Oct 2011 17:19:34 -0000 1.42 +++ spec-source-orientation.html 21 Oct 2011 15:57:05 -0000 @@ -150,6 +150,7 @@
This section is non-normative. + +
The following worked example is intended as an aid to users of the + DeviceOrientation event. + +
Section 2 provided an example of using the + DeviceOrientation event to obtain a compass heading when the device is held + with the screen horizontal. This example shows how to determine the compass + heading that the user is 'facing' when holding the device with the screen + approximately vertical in front of them. An application of this is an + augmented-reality system. + +
More precisely, we wish to determine the compass heading of the horizontal + component of a vector which is orthogonal to the device's screen and pointing + out of the back of the screen. + +
If represents this vector in the rotated device + body frame xyz, then + + +
The transformation of due to the rotation about + the z axis can be represented by the following rotation matrix. + +
+ + +
The transformation of due to the rotation about + the x axis can be represented by the following rotation matrix. + +
+ + +
The transformation of due to the rotation about + the y axis can be represented by the following rotation matrix. + +
+ + +
If resresents the vector + in the earth frame XYZ, then since the inital body frame is aligned with the + earth, is as follows. + +
+ + +
+ + +
+ + +
+ + +
+ + +
The compass heading is given by + +
+ + +
provided that and + are not both zero. + +
As a consistency check, if we set + , then + +
+ + +
as expected. +
Lars Erik Bolstad, Dean Jackson, Claes Nilsson, George Percivall, Doug Turner, Matt Womer