1

Is there a formula to convert a quaternion to an angle?

Looking to do something on the iPhone using the Core Motion API and the gyro so that based on data I receive from it (in the form of quaternions) I can project a UIView on the screen.

Thanks

wgpubs
  • 8,131
  • 15
  • 62
  • 109

1 Answers1

7

Yes, see Quaternions and spatial rotation. The unit quaternion (w, x, y, z) represents a rotation about the axis (x, y, z) of an angle of 2*cos-1(w).

Note that this is only true of unit quaternions. Non-unit quaternions do not represent rotations.

Adam Rosenfield
  • 390,455
  • 97
  • 512
  • 589
  • Is this going to give me both the horizontal and vertical angles? Again, I'm working with an iPhone 4 and try to project a UIView on to the screen based on how the phone is being held. thanks – wgpubs Sep 29 '10 at 21:17
  • Also note, that you need to use the *absolute value* of w to get the minimal angle. – quasi Jun 27 '22 at 13:30