0
$\begingroup$

I'm trying to write a program to convert a quaternion to a rotation matrix. One source I found is: http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation#Conversion_to_and_from_the_matrix_representation

A second source is: https://stackoverflow.com/questions/1556260/convert-quaternion-rotation-to-rotation-matrix

I am pretty sure that for the variable names, a=w, b=x, c=y, d=z, but that doesn't explain the fact that the two matrices look completely different. When I try to implement them, the second one looks right whereas the first one looks wrong. What is the difference between the two matrices?

$\endgroup$
1
  • 1
    $\begingroup$ You may be more likely to get an answer if you make your question more self-contained by including the matrices you are asking about. $\endgroup$ Feb 21 '13 at 4:02
0
$\begingroup$

There are two differences. One is that the second matrix is $4\times4$ because it represents an affine transform, which can accommodate translations but in this case doesn't; the fourth component doesn't interact with the other three and you can just ignore it for purposes of comparing the two matrices.

The second difference is in the diagonal elements. To see that the diagonal elements are in fact equal, note that the first answer assumes and the second answer ensures that $a^2+b^2+c^2+d^2=1$. Thus $a^2+b^2=1-c^2-d^2$, which you can use to transform the first diagonal elements into each other, and likewise with the other two pairings of the four variables for the other two diagonal elements.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.