Guest User

Untitled

a guest
Aug 30th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. float accX = Gdx.input.getAccelerometerX(),
  2. accY = Gdx.input.getAccelerometerY(),
  3. accZ = Gdx.input.getAccelerometerZ();
  4.  
  5. float moduleValue = (float) Math.sqrt(accX * accX + accY * accY + accZ * accZ);
  6.  
  7. //Here I do the gravity compensation
  8. accX /= moduleValue;
  9. accY /= moduleValue;
  10. accZ /= moduleValue;
  11.  
  12. float xRotation = (float) Math.atan2(accY, accZ) * MathUtils.radiansToDegrees,
  13. zRotation = (float) Math.atan2(accY, accX) * MathUtils.radiansToDegrees;
Add Comment
Please, Sign In to add comment