   How do you use Quaternions to do rotations
  Ok, I wan't to do rotations with quaternions, but I do not understand quaternions. What I want to do is rotate a given amount, but only rotate a little portion of it at a time. I also want to be able to get the angle of a rotation.Here is some of the code I am using (however, I have little clue as to what I am doing in the main part):   void DirectionalCameraRotator::updateCamera(const FrameEvent &evt){    long tmp;    Real rotateFactor = rotationDegreesPerSecond * evt.timeSinceLastFrame;    //update the camera on the Y axis    tmp = input->getMouseRelativeX();    if (invertRotations)   //invert the sign if we ARE inverting rotations   tmp ^= 0x80000000;    if (tmp < 0)   yaw(-rotateFactor); //cameraNode->yaw(-rotateFactor);    if (tmp > 0)   yaw(rotateFactor); //cameraNode->yaw(rotateFactor);    //update the camera on the X axis    tmp = input->getMouseRelativeY();    if (!invertRotations)   //invert the sign if we ARE NOT inverting rotations   tmp ^= 0x80000000;    if (tmp < 0)   pitch(-rotateFactor); //cameraNode->pitch(-rotateFactor);    if (tmp > 0)   pitch(rotateFactor); //cameraNode->pitch(rotateFactor);    //    //!!! THE REAL MEAT AND POTATOES PART OF THE FUNCTION !!!    //(so to speak)    //    Real theta;    Vector3 axis;    Quaternion deltaRotation;    //get the rotation    rotations.ToAngleAxis(theta, axis);    //restrict the rotation to the maximum    if (Math::Abs(theta) > rotateFactor) {   Real factor = rotateFactor / rotationDegreesPerSecond;   deltaRotation = Quaternion::Slerp(factor, Quaternion::IDENTITY, rotations);   rotations = rotations * deltaRotation.Inverse();    } else {   deltaRotation = rotations;   rotations = Quaternion::IDENTITY;    }    //set new rotation    cameraNode->rotate(deltaRotation);}u r what u bcome[edited by - bcome on February 5, 2004 9:13:52 PM][edited by - bcome on February 5, 2004 9:18:13 PM]
quote:Original post by bcome  but I do not understand quaternionsThere''s your problem. Learn them. There are many resources to help you.;  yeah, start by reading the articles in the "Articles & Resources" section of this site on quaternions.  there's enough there to get you understanding them farily well.  Particularly the gamasutra article on quaterions is a great introductory article.  Other than that, google for "quaternion tutorial" or something and read about it.  you'll break your brain trying to just use quaternions in a zen way without any understanding of the math behind them.  they are quirky and the only way to make your quaternion class work is to understand WHY they are quirky.  things like order of operations are crucial in quaternions as is how modify them to represent new rotational states, etc. So read up.-me   [edited by - Palidine on February 5, 2004 11:45:50 PM]