How are these formulas for Quaternion -> Rotation Matrix related?

417 Views Asked by At

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?

1

There are 1 best solutions below

0
On BEST ANSWER

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.