Are there different conventions for representing rotations as quaternions?

Found earlier answer How do you rotate a vector by a unit quaternion?

I will look for the place where I gave a really complete answer, but there are two versions for a very simple reason. You have a unit quaternion $\xi = a + b i + c j + d k.$ You have a vector in $\mathbb R^3,$ which is regarded as a "pure" quaternion $\alpha = x i + y j + z k.$ Finally, the is the conjugate $\bar{\xi} = a - b i - c j - d k.$ Unit means $a^2 + b^2 + c^2 + d^2 =1,$ so $\xi \bar{\xi} = \bar{\xi} \xi = 1.$

The two linear mappings you are finding are: $$ \xi \alpha \bar{\xi} $$ OR $$ \bar{\xi} \alpha \xi. $$

Either recipe works, for the simple reason that the "real part" of any quaternion product $\beta \gamma$ is the same as the real part of $\gamma \beta.$ So, given that the real part of $\alpha$ is $0,$ the real part of $ ( \bar{\xi} \alpha ) \xi $ is the same as the real part of $ \xi ( \bar{\xi} \alpha ) $ is the same as the real part of $ (\xi \bar{\xi}) \alpha $ is the same as the real part of $ \alpha $ which is $0.$ So the result is another vector, another pure quaternion.


What you are looking at is the translation of a quaternion rotation into a rotation matrix, that is, a $3\times 3$ matrix which you multiply vectors on a side to perform the rotation. There aren't really rotations by quaternions in that expression, just the ordinary representation of a rotation by a matrix.

The reason that your first matrix is the transpose of the other is simple: in one case they are following a convention of multiplying vectors on the right, and in the other case they are multiplying vectors on the left.

To make an analogy with two dimensions, $$ \begin{bmatrix}\cos(x)&-\sin(x)\\\sin(x)&\cos(x)\end{bmatrix} $$

is the rotation matrix if vectors are column vectors on the right, and

$$ \begin{bmatrix}\cos(x)&\sin(x)\\-\sin(x)&\cos(x)\end{bmatrix} $$

is the matrix for the same rotation if the vectors are row vectors on the left.


The main way of representing 3-d rotations in terms of quaternions is this: you view the space of quaternions with zero real part as 3-space, and conjugate with the unit quaternions to produce rotations. Specifically, if $h$ is a unit quaternion pointing along the axis of rotation, and $\theta$ is the angle of rotation (measured right-handedly with respect to $h$), then $\cos(\theta) +h\sin(\theta)=q$ is a unit quaternion, and $v\mapsto qvq^{-1}$ produces the rotation.

There are some pretty good descriptions here: https://math.stackexchange.com/a/331547/29335

and here: https://math.stackexchange.com/a/331203/29335


I have looked more carefully at these references and I have figured out what the difference is. The difference is that the Diebel paper and the references that agree with it define the quaternion as the rotation of the coordinate system, which is the opposite direction of the rotation of the vector in the system. For instance, if I have two coordinate systems A and B, and system B is system A rotated 30 degrees counterclockwise around the Z axis, then if I have a vector in system A that I want to express in system B, I have to rotate the vector 30 degrees clockwise around the Z axis. A diagram that shows this is in figure 1 of Diebel's paper. This explains why there is the transposition discrepancy (because the transpose of a rotation matrix is its inverse). All the references use the form with the vectors being column vectors, and use the $\xi \alpha \bar{\xi}$ form.