title: Android getOrientation() method returns bad results
body: <p>I'm creating 3D Compass application.</p>
  
  <p>I'm using <a href="http://developer.android.com/reference/android/hardware/SensorManager.html#getOrientation%28float%5B%5D,%20float%5B%5D%29" rel="nofollow noreferrer">getOrientation</a> method to get orientation (almost same implementation like <a href="https://stackoverflow.com/questions/2963705/using-getrotationmatrix-and-getorientation-in-android-2-1">here</a>). If I place phone on the table it works well, but when top of the phone points to the sky (minus Z axis on the picture; sphere is the Earth) getOrientation starts giving really bad results. It gives values for Z axis between 0 to 180 degrees in a few real degrees. Is there any way how to suppress this behavior? I created a <a href="http://youtu.be/U1o5TsCKOd0" rel="nofollow noreferrer">little video</a> what describes problem (sorry for bad quality). Thanks in advance.</p>
  
  <p><img src="https://i.stack.imgur.com/SrPhl.gif" alt="enter image description here"></p>
  
  <p><strong>Solution</strong>:
  When you rotating model, there is difference between:</p>
  
  <pre><code>gl.glRotatef(_angleY, 0f, 1f, 0f); //ROLL
  gl.glRotatef(_angleX, 1f, 0f, 0f); //ELEVATION
  gl.glRotatef(_angleZ, 0f, 0f, 1f); //AZIMUTH
  
  
  gl.glRotatef(_angleX, 1f, 0f, 0f); //ELEVATION
  gl.glRotatef(_angleY, 0f, 1f, 0f); //ROLL
  gl.glRotatef(_angleZ, 0f, 0f, 1f); //AZIMUTH
  </code></pre>