title: Getting Direction Vector in Android
body: <p>How can I get a direction vector representing the direction the back of the device is pointing relative to earth coordinates?</p>
  
  <p>For example, if place down on a desk (screen facing up) it should read [0,0,-1] and if held vertically facing north it should read [1,0,0], etc.</p>
  
  <p>I know how to calculate it from heading, pitch, and roll, as long as those are relative to earth coordinates.  To be clear here I am not looking for angular velocity, but the actual current angle relative to the plane tangent to the earth.  So if the device is held vertically and facing north, the angle "alpha" should read 0 or 360, the angle "beta" should read 90, and "gamma" should read 0. I can't figure out how to get these values either.</p>
  
  <p>I've been reading the API all day and I still cannot find how to get either of these things.</p>
  
  <pre><code>public void onSensorChanged(SensorEvent event) {
      // ?    
  }
  </code></pre>
  
  <p>Thanks for any insights.</p>