Jump to content
  • Advertisement
Sign in to follow this  
SFSpoto

Quaternion rotation

This topic is 4640 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi to all. I compute three rotation quaternions and then multiply them for obtain a TOTAL rotation matrix. In this way: // create quaternion for rotation around y axis qYaw.CreateRotationQuaternion(0.0f, 1.0f, 0.0f,yawDegree); // create quaternion for rotation around x axis qPitch.CreateRotationQuaternion(1.0f, 0.0f, 0.0f, pitchDegree); // create quaternion for rotation around z axis qRoll.CreateRotationQuaternion(0.0f, 0.0f, 1.0f, rollDegree); // then i multiply them for obtain total rotation quaternion q = qRoll * qYaw * qPitch; q.CreateQuaternionMatrix(rMatrix); glMultMatrixf(rMatrix); // now after glMultMatrixf(rMatrix); // the rotation seem to work well. // But then i extract view vector form rMatrix in this way: viewVect.x = Matrix[2]; viewVect.y = Matrix[6]; viewVect.z = Matrix[10]; posVect.x +=viewVect.x; posVect.y +=viewVect.y; posVect.z +=viewVect.z; // then i traslate glTranslatef(-posVect.x, -posVect.y, posVect.z); // BUT the traslation seem to be bloked on a certain axis I think that is not the look vector thet i get from rotation matrix. How can i get the look vect at this point? Tnx very much.

Share this post


Link to post
Share on other sites
Advertisement
I'm wondering why you're negating some of your translation components. Which leads to another question - are you trying to set up an object matrix (say, for rendering your object) or a view matrix? Anyway, parts of your code indicate the former and parts point toward the latter, which is probably why it's not working as you expect.

Share this post


Link to post
Share on other sites
hei tnx, i have corrected that and traslation now seem to work well BUT...this kind of camera can suffers of gimbal lock or something similar? The camera work well for a lot but when i see the object from backward the rotation on the x axis became a rool. Why?
Tnx.

Share this post


Link to post
Share on other sites
ya, your camera will suffer gimbal lock. you're still using euler angles, you're just doing your rotations with quaternions. using quaternions is not the magic gimbal lock remover. to me it looks like you're keeping 3 angles and each screen you build a NEW matrix that is yaw, pitch, roll. to avoid gimbal lock you keep your last camera matrix, and you concatinate to it with new rotations. that is to say you dont rebuild it each time using 3 euler angles.

Tim

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!