c++ - how to negate GLM quaternion rotation on any single axis? -


i have quaternion derived sensors rotates "camera" within opengl es scene. apply inverse of quaternion objects in scene, "facing" "camera" - works expected. issue need negate rotation on z axis these objects. how come quaternion has no rotation within z component?

my tests: have attempted extract euler angles, create negating quaternion , build rotation matrix these objects multiplication of 2 quaternions - results incorrect.

glm::quat rmq = cam->getcameraquaternion();// retrieve camera quat glm::vec3 = glm::eulerangles((rmq))* 3.14159f / 180.f; // euler angle set derived glm::quat rmz = glm::angleaxis(-a.z, vec3(0.0f, 0.0f, 1.0f)); // negating quaternion glm::mat4 fm = glm::inverse(glm::mat4_cast(rmq*rmz)); //final mat4 gl rotation 

there no "rotation on z axis" when use quaternions, axis , angle. need convert euler, flip sign of 1 component, convert quaternions.

for euler angles define order of rotations. rotations not commutative, order matter, , that's why there no generic decomposition of rotation components. order xyz, there no reason why has way. in apis choose order.


Comments