I'm trying to use directX's D3DXQuaternionRotationMatrix() function to retrieve the rotation quaternion from a matrix. The matrix was generated by Blender (an open-source 3D graphics environment ) and is used to reorient a mesh object for use in DirectX. The problem is that the above function only returns a "w" value in the quaternion. Here is matrix followed by function:
D3DXMATRIX mA;
._11 = 1;
._12 = 0;
._13 = 0;
._14 = 0;
._21 = 0;
._22 = 0;
._23 = 1;
._24 = 0;
._31 = 0;
._32 = 1;
._33 = 0;
._34 = 0;
._41 = 0;
._42 = 0;
._43 = 0;
._44 = 1;
D3DXQUATERNION qA;
D3DXQuaternionRotationMatrix( &qA, &mA );
D3DXQuaternionConjugate( &qA, &qA );
result:
qA.x =
qA.y =
qA.z = 0;
qA.w = 0.707
This quaternion doesn't represent any rotation...the matrix, however, does have rotation...what is this rotation? why doesn't the function provide an accurate result?
Your matrix:
1; 0; 0; 0;
0; 0; 1; 0;
0; 1; 0; 0;
0; 0; 0; 1;
This is identity matrix with y and z swapped: Your scene is either Y-Up or Z-Up, and Blender expects D3D to be the opposite, so it uses this matrix to swap y and z. You can think of it as a rotation if you want to, but end result is the same.