title: How to calculate rotation of Android phone relative to phone
body: <p>How do you calculate the amount the phone has rotated?, where the "zero degrees" is something you specify.</p>
  
  <p>For example, say you have your phone flat infront of you on a table in a portrait position - let's call that "zero degrees".</p>
  
  <p>You rotate the phone to the right so that it is now landscape (top of phone pointing right) - that would be "90 degrees".</p>
  
  <p>During this rotation, the phone would've rotated 20, 30, 40 etc degrees</p>
  
  <p>So far, I've found the way to detect phone rotation is via accelerometer and compass, ie "<code>getAzimuth()</code>". However, "zero degrees" is always North.</p>
  
  <p>Is there a way to calculate the rotation of the phone not in relation to cardinal directions?</p>
  
  <p>Notes:</p>
  
  <ul>
  <li>Using libgdx, though the sensor behaviour shouldn't differ that much</li>
  <li>"<code>getRotation()</code>" seems to be able to determine rotations at 0, 90, 270 degrees but not values in between</li>
  <li>Phone I'm using doesn't have gyroscope, and ideally solution won't need gyroscope either</li>
  </ul>
  
  <p>Thanks :)</p>