Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I am trying to use quaterions to move the camera direction vector in the following way.

This code is perfectly working

        glm::quat temp1 = glm::normalize( glm::quat((GLfloat)( -Input1.MouseMove.x  * mouse_sens * time_step), glm::vec3(0.0, 1.0, 0.0)) );
        glm::quat temp2 = glm::normalize( glm::quat((GLfloat)( -Input1.MouseMove.y  * mouse_sens * time_step), dir_norm) );

        Camera1.SetCameraDirection(temp2 * (temp1 * Camera1.GetCameraDirection() * glm::inverse(temp1)) * glm::inverse(temp2));

this code is not

        glm::quat temp1 = glm::normalize( glm::quat((GLfloat)( -Input1.MouseMove.x  * mouse_sens * time_step), glm::vec3(0.0, 1.0, 0.0)) );
        glm::quat temp2 = glm::normalize( glm::quat((GLfloat)( -Input1.MouseMove.y  * mouse_sens * time_step), dir_norm) );

        glm::quat temp3 = temp2 * temp1;
        Camera1.SetCameraDirection(temp3 * Camera1.GetCameraDirection() * glm::inverse(temp3));

Why I cannot multiply quaterions successfully? Am I using GLM in a wrong way?

share|improve this question
    
related gamedev.stackexchange.com/questions/53723/… –  danijar Sep 22 '13 at 11:51
1  
How is it not working? –  ltjax Sep 23 '13 at 16:06
    
The two pieces of code, from my understanding of glm, should produce the same result. However, they are not. The first piece of code produce expected result. In the second piece of code when i move the mouse I get extremely small movements in an apparently random direction. –  Marco Sep 23 '13 at 19:24
1  
Have you tried flipping temp2 and temp1 ? Don't forget that quaternion multiplication is *not commutative*( A*B != B*A ). –  akaltar Dec 24 '13 at 1:43
    
Try to normalize your quaternions after each multiplication. –  kolenda Mar 6 at 16:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.