Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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: http://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?

share|improve this question
1  
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. –  Trevor Wilson Feb 21 '13 at 4:02

1 Answer 1

up vote 0 down vote accepted

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.

share|improve this answer

Your Answer

 
discard

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

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