I have a spaceship flying through a $3D$ space. The flight is determined by applying a quaternion to the look, up, and cross vectors with the following scheme (this is working perfectly):

starting values: cross: $(1, 0, 0)$ up: $(0, 1, 0)$ look: $(0, 0, 1)$

to apply yaw:

  1. set quaternion axis to up vector and set quaternion angle to change in yaw
  2. rotate look and cross vectors by quaternion

to apply pitch:

  1. set quaternion axis to cross vector and set quaternion angle to change in pitch
  2. rotate up and look vectors by quaternion

to apply roll:

  1. set quaternion axis to look vector and set quaternion angle to change in roll
  2. rotate cross and up vectors by quaternion

All three vectors are always normalized.

All three vectors remain orthonormal to one another.

The direction of the velocity of the ship is set to the look vector.

This works great. I have thoroughly tested it. I fly my ship through 3D space with full freedom of movement across all three axes and no singularities.

The problem I cannot solve is rotating the spaceship model so that it corresponds with the orientation of the look, up and cross vectors. I need to create a vector with the following values: ($x$-axis rotation, y-axis rotation, z-axis rotation) I can set the Euler order to any order I want. I have used everything I know about trig and linear algebra for about the last 48 hours, but I just can't seem to find a way to get the axis rotations from the normalized directional vectors. Thanks ahead of time for any help.

  • 1
    $\begingroup$ Your coordinate frame essentially encode a rotation matrix, and you want to convert it into Euler angles. Have you looked at the (admittedly sprawling, disorganized, and confusing) Wikipedia section on the topic? en.wikipedia.org/wiki/… $\endgroup$ – user7530 Dec 17 '14 at 4:32

I am able to represent the rotation of the model with a quaternion that is the product (i.e., $\Pi$ product) of all rotations that have been applied to the model space. Every time a rotation quaternion is applied to the basis vectors of the model space (i.e., cross, up, and look vectors), the total product quaternion is multiplied by that instant quaternion.

| cite | improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.