title: IMU device - How to obtain horizontal rotation angle by calculating euler angle when device is vertical
body: <p>I read some information about rotation method such as euler angle and quaternion, commonly the imu device z axix is pointing up, and around this axis angle  of rotation is yaw that is i need device direction data, but not i must put the device in the pocket, then z axis(like follow picture) will be pointing forward so how can i get the device absolute direction Relative to the north horizon angle when device is rotate?
  <a href="https://i.stack.imgur.com/pdFpI.png" rel="nofollow noreferrer">coordinate</a></p>