I have a field defined by 8 points. From these points, I calculate the axes and create a rotation matrix as follows:
axis[0], axis[1], axis[2] mat = { axis[0].x axis[1].x axis[2].x 0 axis[0].y axis[1].y axis[2].y 0 axis[0].z axis[1].z axis[2].z 0 0 0 0 1 }
I have a specific rotation matrix:
{ -1 0 0 0 0 0 1 0 0 -1 0 0 0 0 0 1 }
As far as I know, this is a valid rotation matrix. Its inversion is equal to its transposition.
Now I would like to save this matrix as a quaternion. But later I need a rotation matrix to be recreated from this quaternion. I believe that the conversion from matrix to quaternion and back to matrix should be an identity transformation, and I should get the same matrix as at the beginning (possibly with very small numerical errors).
But this does not seem to be the case. Both SlimDX (C #) and my math library (C ++) return an invalid matrix.
First, the quaternion that I get:
C#: 0, 0, 0.70710676908493, 0 C++: 0, -0.707107, 0, 0
And the matrix created from this quaternion:
WITH#:
0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 1
C ++:
0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 1
Why is this wrong?
I also tried this: http://cache-www.intel.com/cd/00/00/29/37/293748_293748.pdf , but it also gave me poor results.