Take the 2-minute tour ×  I have accelerometer values for the 3
axis(usually when there is only gravity contains data between
-1.0 and 1.0 ):    float Rx;   float Ry;   float Rz;  I make
soma calculations, then I get the angles for each axis.    float
R =  sqrt(pow(Rx,2)+pow(Ry,2)+pow(Rz,2));   float Arx =
acos(Rx/R)*180/M_PI;   float Ary = acos(Ry/R)*180/M_PI;   float
Arz = acos(Rz/R)*180/M_PI;  Then I set the values for the box
angles in opengl  rquad = Arx; yquad = Ary;  Which rotates my
box:   It work on hemisphere. I would like to use the full
sphere and I know that I have to use the Arz value to make it
work, but I don't know how can I use that for this rotation.
Could you help me?  Update: The final answer is in my case:
rquad = -atan2(Rx/R, Rz/R)*180/M_PI;   yquad = -atan2(Ry/R,
Rz/R)*180/M_PI; share|improve this question  2 Answers 2  up
vote 13 down vote accepted  The correct answer is:  Roll =
atan2(Y, Z) * 180/M_PI; Pitch = atan2(-X, sqrt(Y*Y + Z*Z)) *
180/M_PI;  Source: http://www.freescale.co