Search code examples
c++rotationglm-matheuler-angles

Which euler angle order does this code result in?


Using the mathematics library GLM, I use this code to combine the euler angle rotations to a rotation matrix.

#include <GLM/gtc/matrix_transform.hpp>
using namespace glm;

mat4 matrix = rotate(mat4(1), X, vec3(1, 0, 0))
            * rotate(mat4(1), Y, vec3(0, 1, 0))
            * rotate(mat4(1), Z, vec3(0, 0, 1));

Does this result in an euler angle sequenze of XYZ or ZYX? I am not sure since matrix multiplication behave not the same as scalar multiplications.


Solution

  • Remember that matrix calculation, in openGL, use a notation knows as vector column (http://en.wikipedia.org/wiki/Column_vector). So, any point transformation will be expressed by a system of linear equation, expressed in vector column notation like this:

    [P'] = M.[P], where M = M1.M2.M3

    This means that the first transformation that is applied to the points, expressed by vector [P] is M3, after that by M2 and at last by M1.

    Answering your question, the resulting Euler angle will be ZXY, once Z rotation transformation is the last matrix that you write to form a matrix multiplication.