Rotation order for eulers getPitch(), getRoll(), getYaw() from Quaternion in libgdx?

柔情痞子 提交于 2019-12-11 03:41:10

问题


When transforming a quaternion to Euler Angles, usually there has to be a order in which the axes are rotated, like in this visualization.

How does it work for libgdx?

The Quaternion class has the functions

getRoll():

Math.asin(MathUtils.clamp(2f * (w*x - z * y), -1f, 1f)) : 
     (float)pole * MathUtils.PI * 0.5f;`

getPitch():

Math.asin(MathUtils.clamp(2f * (w*x - z * y), -1f, 1f)) : 
     (float)pole * MathUtils.PI * 0.5f;`

getYaw():
`
MathUtils.atan2(2f * (y * w + x * z), 1f - 2f * (y * y + x * x)) : 0f;`

Where is the order of the resulting angles set, which axes is rotated first,second,third ?

How are these functions related to a quaternion rotation matrix like:

Why is it that often this Rotationmatrix is given as Inverse /Transposed (equal because of orthogonality) ?


回答1:


Rotation order

There are 12 possible orders of rotations possible for using an angle triplet for orientation.

Six of them are called Proper Euler angles, and rest six are called Tait–Bryan angles.

Read more here

Libgdx uses the following order.

  1. Rotate by yaw about Y
  2. Elevate by pitch towards Y
  3. Rotate by roll about obtained direction

Rotation Matrix

Rotation matrices, Quaternions, Euler angles and Axis-Angle representation are different ways to encode rotation/orientation.

They often trade off between storage space and computation cost.

They can be freely converted into each other by means of well defined equations, one of which you mentioned. So these conversion expressions are related to each other.


Edit Thanks for pointing out the mistake. It is indeed about Y axis not Z.

I have verified it from the source code.


Libgdx uses coordinate system of bullet physics engine. In that system, XZ plane is considered horizontal and Y is considered upwards (not Z). This was the root of my mistake.



来源:https://stackoverflow.com/questions/41633455/rotation-order-for-eulers-getpitch-getroll-getyaw-from-quaternion-in-lib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!