4
votes

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 vectors 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]

1
If you are happy with an answer witch doesn't match the question title, please consider updating the question title. Thanks.user234736

1 Answers

4
votes

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.