Skip to content
This repository has been archived by the owner on Nov 30, 2022. It is now read-only.

How can I read the XYZ euler angles from a q3Mat3? #56

Open
wmcnamara opened this issue Apr 28, 2021 · 1 comment
Open

How can I read the XYZ euler angles from a q3Mat3? #56

wmcnamara opened this issue Apr 28, 2021 · 1 comment

Comments

@wmcnamara
Copy link
Contributor

wmcnamara commented Apr 28, 2021

I am having a bit of trouble extracting the XYZ euler angles from a 3x3 rotation matrix. I have this code that updates the position based on the transform given from the GetTransform() function.

const q3Transform& tr = body->GetTransform();
m_transform.SetPosition(tr.position)

I want to be able to set a rotation aswell, but I am not sure how to extract euler angles from the rotation matrix in the transform variable.

How would I go about getting euler angles from a rotation q3Mat3?

@RandyGaul
Copy link
Owner

Hi there, this is a math question unrelated to qu3e, but we can find some solutions with a google search on converting a rotation matrix to euler angles: http://www.close-range.com/docs/Computing_Euler_angles_from_a_rotation_matrix.pdf

There are multiple different sets of euler angles for a single rotation matrix. Typically in 3D games euler angles aren't used by the lower level parts of the engine due to inconvenience in doing so. Sometimes artists or similar like to input euler angles through a user interface, but generally those angles are converted to a rotation matrix for the runtime.

So there's no built-in function in qu3e to do this. But you can write the code to do this yourself, if you like :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants