title: How do I get compass heading from DeviceOrientation in the Google Glass Browser?
body: <p>The web browser built into Google Glass as of firmware version XE7 provides <a href="http://www.w3.org/TR/orientation-event/" rel="nofollow noreferrer"><code>DeviceOreientation</code> events</a>, but the values don't seem to come from an expected frame of reference. How can one get proper compass headings out of this?  With Glass positioned normally on the head:</p>
  <h1>DeviceOrientationEvent</h1>
  <h2>beta</h2>
  <pre><code>     90  upright and level
      -90  inverted and level
        0  looking straight up or down
  </code></pre>
  <h2>gamma</h2>
  <pre><code>     90  right ear towards floor
      180  looking straight up
  270/-90  left ear down
        0  looking straight down
  </code></pre>
  <h2>alpha</h2>
  <p><em>This property is not stable when Glass is horizontal (what should be the most useful orientation for using compass direction, to determine where the wearer is looking). It gives stable readings only when Glass is tilted well above or below the horizon.</em></p>
  <h3>above horizontal</h3>
  <pre><code>     90  North
        0  East
      180  West
      270  South
  </code></pre>
  <h3>below horizontal</h3>
  <pre><code>    270  North
      180  East
        0  West
       90  South
  </code></pre>