Calculating degree from Accelerometer XY Values RRS feed

  • Question

  • I am playing about with the Accelerometer and want to interpret my X, Y values as a degree (angle) value. ie somewhere between 0 and 360.

    How can I do this?

    Wednesday, October 2, 2013 2:09 PM


  • You can use basic trigonometry:

    Tangent(theta) = Opposite/Adjacent.

    View your X and Y are the sides of a right triangle with your angle theta at the origin:
    Theta = arctan(X/Y).


    Wednesday, October 2, 2013 3:17 PM