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


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]]

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


The right value should be some order of value2


It looks two components of value1 are wrongly calculated.

Where does it go wrong?

share|improve this question

Your Answer


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

Browse other questions tagged or ask your own question.