Ogre difference between quaternion

443 views Asked by At

I'm working with quaternion in ogre.
Each frame I get:

 Ogre::Quaternion prev;

 bool frameStarted(const Ogre::FrameEvent& event) {
   const Ogre::Quaternion q = object->getOrientation();
   if(abs(q.x - prev.x) > ...) {
      /* do something */
      prev = q;
   }
 }

How can I check if X-rotation at time T+1 is 180° less than X-rotation at time T?

1

There are 1 answers

1
Richard Vock On

I don't really get what you want to do with the x member of the quaternion. If anything you are comparing the x-coordinate of different rotation axes.

However if I get the question right, you are looking for the difference of rotation angles around the x-axis. In this case http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles explains how you can transform the quaternion into euler-angles which in turn will give you the rotation angles around each canonical basis vector (X, Y and Z). It then amounts to comparing the euler angles (keep in mind they'll be in radians, so use pi instead of 180).