title: Android: axes vectors from orientation/rotational angles?
body: <p>So there's a couple methods in the Android SensorManager to get your phone's orientation:</p>
  
  <pre><code>float[] rotational = new float[9];
  float[] orientation = new float[3];
  SensorManager.getRotationMatrix(rotational, whatever, whatever, whatever);
  SensorManager.getOrientation(rotational, orientation);
  </code></pre>
  
  <p>This gives you a rotation matrix called "rotational" and an array of 3 orientation angles called "orientation". However, I can't use the angles in my AR program - what I need is the actual vectors which represent the axes.</p>
  
  <p>For example, in this image from Wikipedia:<br>
  <img src="https://i.stack.imgur.com/EeWKI.jpg" alt="Euler Angles from Wikipedia"><br>
  I'm basically being given the α, β, and γ angles (though not exactly since I don't have an N - I'm being given the angles from each of the blue axes), and I need to find vectors which represents the X, Y, and Z axes (red in the image). Does anyone know how to do this conversion? The directions on Wikipedia are very complicated, and my attempts to follow them have not worked. Also, I think the data that Android gives you may be in a slightly different order or format than what the conversion directions on Wikipedia expect.</p>
  
  <p>Or as an alternative to these conversions, does anyone know any other ways to get the X, Y, and Z axes from the camera's perspective? (Meaning, what vector is the camera looking down? And what vector does the camera consider to be "up"?)</p>