Loss Conversion Matrix & # 8594; Quaternion & # 8594; Matrix

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.

+4
source share
2 answers

The matrix you gave is not a rotation matrix, it is a reflection matrix because its determinant is -1. See the definition on Wikipedia. You can say that something is wrong, because you have to get a single quaternion, and yet the one you return has a length of 1 / sqrt (2).

+7
source

Try using a 4x4 matrix. I am not a math expert, but I have never used 3x3 matrices when working with 3D graphics. I believe that an extra dimension to normalize or something like that.

0
source

All Articles