Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to write a program to convert a quaternion to a rotation matrix. One source I found is:

A second source is:

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|cite|improve this question
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
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|cite|improve this answer

Your Answer


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.