Skip to content

Documentation of Euler angles conversions #569

Open
@patrikhuber

Description

@patrikhuber

Hi!

Please correct me if I'm wrong. In general, glm seems to adhere to the XYZ convention for Euler angles, meaning you'd left-multiply a column vector to get the rotated vector, like so: [u_n, v_n, w_n]' = X*Y*Z*[u, v, w]'. But in general it doesn't say very often in the documentation which convention exactly glm follows. Sometimes one can guess from the function name.

But take for example glm::eulerAngles(glm::quat q):

float pitch = glm::radians(10.0f); // x axis
float yaw = glm::radians(30.0f); // y axis
float roll = glm::radians(20.0f); // z axis
auto xyz_mat = eulerAngleXYZ(pitch, yaw, roll);
quat q(xyz_mat);	
auto angles = glm::eulerAngles(q); // Quat to angles. pitch yaw roll.
float t1_x, t2_y, t3_z;
glm::extractEulerAngleXYZ(xyz_mat, t1_x, t2_y, t3_z);

The angles in angles are very different from the original angles. glm::extractEulerAngleXYZ however works correctly and returns the same angles. But in what convention are the angles that glm::eulerAngles(q) returns? I can't find it in the documentation. Or maybe I'm having a misconception about the topic at hand?

Apart from that, isn't the documentation ambiguous - if you only say it follows the convention X*Y*Z, it would be either row_vec*X*Y*Z or X*Y*Z*col-vec, which would result in a completely different rotation?

Additionally I have another small question: Is the XYZ (and YXZ) kind of the standard in OpenGL? I have seen the convention ZXY (which would be R*P*Y (roll-pitch-yaw)) applied much more - in fact I think I even remember hearing that RPY is some kind of MPEG or ISO standard convention. In any case I think it would be nice to have a function eulerAngleZXY here.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions