I have a Ogre::Matrix4, and I want to get the quaternion of this rotation. For this I use the extract3x3Matrix function then I am transforming this matrix in quaternion which give me one response. Then I am using the decompose function of Ogre::Matrix4 which give me an other quaternion. The 2 quaternions are different. How is it possible ?
Before applying the decompose function, I'm making sure the transformation is affine.
Ogre::Matrix4 car_T_tracker( 0.0124343, -0.04752782, 1.010372, -1400.69,
0.3480031, -0.9485609, -0.04890297, 647.4758,
-0.9497393, -0.3481936, -0.004690885, 1441.177,
0, 0, 0, 1);
Ogre::Matrix3 rotation_car_T_tracker;
car_T_tracker.extract3x3Matrix(rotation_car_T_tracker);
Ogre::Quaternion q;
q = car_T_tracker.extractQuaternion();
std::cout << "quaternion x : " << q.x << std::endl;
std::cout << "quaternion y : " << q.y << std::endl;
std::cout << "quaternion z : " << q.z << std::endl;
std::cout << "quaternion w : " << q.w << std::endl;
Ogre::Vector3 translation_car_T_tracker;
Ogre::Vector3 scale_car_T_tracker;
Ogre::Quaternion quaternion_car_T_tracker;
if(car_T_tracker.isAffine())
{
car_T_tracker.decomposition (translation_car_T_tracker,scale_car_T_tracker,quaternion_car_T_tracker);
}
else
{
translation_car_T_tracker = Ogre::Vector3::ZERO;
scale_car_T_tracker = Ogre::Vector3::ZERO;
quaternion_car_T_tracker = Ogre::Quaternion::ZERO;
}
std::cout << "translation : " << translation_car_T_tracker << std::endl;
std::cout << "scale : " << scale_car_T_tracker << std::endl;
std::cout << "quaternion : " << quaternion_car_T_tracker << std::endl;
quaternion_car_T_tracker and q are not the same quaternion but they should be.