-
Beta Was this translation helpful? Give feedback.
Answered by
jrouwe
Mar 28, 2025
Replies: 1 comment 3 replies
-
You cannot go from Euler angles to quaternion/matrix and back to the same Euler angles. The 3 Euler angles are not independent and multiple Euler angles represent the same rotation. I would avoid using Euler angles altogether and e.g. rotate the ship by creating a rotation matrix around the forward axis and applying that to the ship's rotation:
|
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Applying forces and torques should work just fine.
To calculate the roll angle you would take the normalized up vector of the ship (U) and the normalized forward vector of the ship (F), project the world up vector (W
= Vec3(0, 1, 0)?
) onto the right/up plane of the ship:Normalize the result:
And then use the dot product to get the roll angle:
This angle is always positive, so you must negate it depending on what you consider to be positive/negative roll.
This approach breaks down when the ship is flying straight up as roll is undefined in this case.