开发者

How to calculate yaw pitch and roll from orientation vectors?

开发者 https://www.devze.com 2023-03-18 02:03 出处:网络
I\'m working with some 3D graphics and I encountered a problem. I have models that move in a world. The models have a base class that contains their orientation in the form of three orthogonal unit ve

I'm working with some 3D graphics and I encountered a problem. I have models that move in a world. The models have a base class that contains their orientation in the form of three orthogonal unit vectors namely Direction, Up, and Right. They point to where the front of the model is directed, the up and the right directions respectively.

The AI of a model pursues a target by changing the Direction vector of the model and all other orientation vectors accordingly, so that it simulates that the model is pointing to the target.

I cannot keep track of the angles that the AI changes the orientation vectors by because the AI files were already pre-compiled and I cannot change them. Also, the AI changes the vectors using the position coordinates of the model and the position coordinates of the target.

My question is how can I obtain yaw, pitch and roll from the orientation vector开发者_如何学Cs in order to create a rotation matrix to rotate the whole model in the desired orientation?

Thanks for any help.

[EDIT] Thanks to the given answer I found this:

               X   Y   Z   W
             -                -
       Right | Rx  Ry  Rz  Rw |
          Up | Ux  Uy  Uz  Uw |
    -Forward |-Fx -Fy -Fz -Fw |
 Translation | Tx  Ty  Tz  Tw |
             -                -

This is how the matrix should be set up to obtain the world matrix using the orientation vectors (without scaling: to scale, just create a scale matrix and multiply it by this).

[SOLVED]


You do not need yaw, pitch and roll. The three orthogonal unit vectors Direction, Up, and Right give you the rows of the rotation matrix. It is that simple.

See from 41:58 in Sensor Fusion on Android Devices: A Revolution in Motion Processing.

By the way, you can easily get into trouble with yaw, pitch and roll, see from 38:25.

0

精彩评论

暂无评论...
验证码 换一张
取 消