Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Here is an old quaternions package.

There is a function named MatrixToQuaternion,

References are here

Matrix in that document is 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; you can see it in the top of the page.

m1 is a test matrix

m1={{-0.825927,-0.56376,0.00445629,-166.077},{-0.56376,0.825813,-0.0144323,-109.866},{0.00445629,-0.0144323,-0.999886,200.868},{0.,0.,0.,1.}};

Part of the MatrixToQuaternion function in the package Quaternions.m

You can check this according the web page.

S =  2*Sqrt[1 + m1[[2,2]] - m1[[1,1]] - m1[[3,3]]]; 

    Quaternion[m1[[1,3]] + m1[[3,1]], 
        m1[[1,2]] + m1[[2,1]], 
                1/2, m1[[2,3]] + m1[[3,2]]
    ]/S

gives value1 (you can simply Total[#^2]& to see it's wrong unit quaternion)

Quaternion(0.00233201,-0.29502,0.130827,-0.00755253)

The right value should be some order of value2

{-0.29502,0.955461,-0.00755253,0.}

It looks two components of value1 are wrongly calculated.

Where does it go wrong?

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.