Hi,

I am making some custom matrices with some initial instruction on the Opengl thread. Its mostly turned into a math issue, so I've placed the question here; hope that's ok. My goal was to make the Euler rotational matrices "by hand" which took some additional internet research. In most of the three Euler angle matrices, the matrix only produces identical GLM results if the "-" in front of the sine fx isto the other sine fx in the matrix. Both methods and results are posted below. I've found it by empirical testing, not a formal proof. But its the only way it will work.moved

Code :glm::mat4 rotx(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( 1.0f,0.0f,0.0f,0.0f, 0.0f, c, -s, 0.0f, 0.0f, s, c, 0.0f, 0.0f,0.0f,0.0f,1.0f ); } glm::mat4 roty(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( c, 0.0f, s, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, -s, 0.0f, c, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); }; glm::mat4 rotz(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( c,-s,0.0f,0.0f, s,c,0.0f,0.0f, 0.0f,0.0f,1.0f,0.0f, 0.0f,0.0f,0.0f,1.0f ); };

GLM result:

Rotate vector custom fx on x axis:vec4(4.000000, -5.156932, 5.865666, 1.000000)

Rotate vector by GLM on x axis: vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector custom fx on y axis:vec4(6.545196, 5.000000, -3.026618, 1.000000)

Rotate vector by GLM on y axis: vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector custom fx on z axis:vec4(-4.323152, 4.723384, 6.000000, 1.000000)

Rotate vector by GLM on y axis: vec4(5.557164, -3.180869, 6.000000, 1.000000)

If I swap minus sign positions, GLM compares nicely.

Code :glm::mat4 rotx(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( 1.0f,0.0f,0.0f,0.0f, 0.0f, c, s, 0.0f, 0.0f, -s, c, 0.0f, 0.0f,0.0f,0.0f,1.0f ); } glm::mat4 roty(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( c, 0.0f, -s, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, s, 0.0f, c, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f); }; glm::mat4 rotz(float a) { float s = std::sin(a); float c = std::cos(a); return glm::mat4( c,s,0.0f,0.0f, -s,c,0.0f,0.0f, 0.0f,0.0f,1.0f,0.0f, 0.0f,0.0f,0.0f,1.0f ); };

Rotate vector custom fx on x axis:vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector by GLM on x axis: vec4(4.000000, 6.699447, -4.014649, 1.000000)

Rotate vector custom fx on y axis:vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector by GLM on y axis: vec4(-5.311184, 5.000000, 4.877635, 1.000000)

Rotate vector custom fx on z axis:vec4(5.557164, -3.180869, 6.000000, 1.000000)

Rotate vector by GLM on y axis: vec4(5.557164, -3.180869, 6.000000, 1.000000)