[Math] Are there different conventions for representing rotations as quaternions

matricesquaternionsrotations

I am trying to understand how quaternions are represented as rotations, in particular how to convert from a quaternion representation to a rotation matrix. The following paper by Diebel gives an overview of many ways to represent rotations, including quaternions:

http://www.swarthmore.edu/NatSci/mzucker1/e27/diebel2006attitude.pdf

According to Diebel, a quaternion $a+bi+cj+dk$ corresponds to the following rotation matrix:

$\left( \begin{array}{ccc}
a^2+b^2-c^2-d^2 & 2bc+2ad & 2bd-2ac \\
2bc-2ad & a^2-b^2+c^2-d^2 & 2cd+2ab \\
2bd+2ac & 2cd-2ab & a^2-b^2-c^2+d^2 \end{array} \right)$

(This is equation 125 on page 15, just with the $q_0,q_1,q_2,q_3$ replaced with $a,b,c,d$ respectively.)

In contrast, on the Wikipedia page:

http://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation

the following matrix is given:

$\left( \begin{array}{ccc}
a^2+b^2-c^2-d^2 & 2bc-2ad & 2bd+2ac \\
2bc+2ad & a^2-b^2+c^2-d^2 & 2cd-2ab \\
2bd-2ac & 2cd+2ab & a^2-b^2-c^2+d^2 \end{array} \right)$

Note that this is not the same matrix as the one above (it is the transpose).

I have looked at some other references and I can find some that give the first matrix, and some that give the second matrix. For example, the following references agree with the matrix given by Diebel:

http://www.cs.princeton.edu/~gewang/projects/darth/stuff/quat_faq.html (question 54)
http://www.ladispe.polito.it/corsi/Meccatronica/02JHCOR/2011-12/Slides/Shuster_Pub_1993h_J_Repsurv_scan.pdf (equation 158)

(Note that some of these references use different names for the four quaternion components or put them with the scalar as the last instead of the first element; you can easily tell the difference in the two forms by seeing if the item in the first row, second column has a "+" or a "-" sign.)

But the following references agree with the matrix given by the Wikipedia article:

http://naif.jpl.nasa.gov/pub/naif/toolkit_docs/FORTRAN/spicelib/q2m.html (under "Associating SPICE Quaternions with Rotation Matrices")

http://books.google.com/books?id=hiBFUv_FT0wC&printsec=frontcover&dq=game+programming+gems+volume+1&hl=en&sa=X&ei=LQ-IUZ7CLKmpyAG66IGIDA&ved=0CEAQ6AEwAQ#v=onepage&q=convert%20quaternion%20to%20rotation%20matrix&f=false
(page 202)


What is the cause of this difference? Since there are several references that use each of these two matrices, it seems unlikely that it is simply an error in one of the references. Are there different conventions for how to represent rotations by quaternions that would lead to this difference?

Best Answer

This is a very old question, but none of the responses directly answer the question.

In short, YES, there are two different Quaternion conventions. The original question even hints at the answer-- there is the JPL convention, used at parts of NASA, JPL, some spacecraft stuff, etc; and there is the original Hamiltonian convention used by almost everyone else.

For a discussion of how and why this happens, see the following article: https://arxiv.org/abs/1801.07478

This paper also describes the difference, and is generally an excellent reference for how Quaternions are used in certain navigation applications: https://arxiv.org/abs/1711.02508

Related Question