# Rotation about z axis using quaternions

I am working with quaternions and rotation, but I am missing something about how a rotation expressed as a quaternion works. I also discovered that there are different convention for quaternions (JPL, Hamilton, ESA, etc...) and I decided to stick to the Hamiltonian convention. Therefore we are talking about quaternions in the form $q = (\vec\xi, \eta )$. With the following properties:

• Algebra: $ij =k$
• Rotation Function: Passive (transforms reference frames and not point)

Consider now a vector expressed in quaternion rotation $\mathbf{v} = (\vec v, 0)$. We want to express the point in a new reference frame and we use the quaternion rotation $$\mathbf{v'} = \mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q^*}$$

Where $\mathbf{q^*}$ is the conjugate. Now consider the exponential mapping from a rotation vector to a unit quaternion $$\mathbf{q} = e^{v\theta} = \left(\mathbf{\hat{u}}\sin\left(\frac{\theta}{2}\right), cos\left(\frac{\theta}{2}\right)\right)$$.

So far so good, however when I apply this theory to a simple example the results do not convince me.

Example

Consider a reference frame A expressed by the three vectors $$\mathbf{x_A} = [1,0,0]^T \\ \mathbf{y_A} = [0,1,0]^T \\ \mathbf{z_A} = [0,0,1]^T$$ Consider now the reference frame B that is the result of a right handed rotation about $z_A$ of $\pi/2$. This in my mind corresponds to a counter-clockwise rotation. After that I am expecting the frame B to have the same $\mathbf{z}$, $\mathbf{y_B}$ opposite to $\mathbf{x_B}$ and $\mathbf{x_A}$ aligned with $\mathbf{y_B}$. Using the aforementioned formula, the quaternion from A to B is $$\mathbf{q_{AB}} = \left(\mathbf{z_A}\sin\left(\frac{\pi}{4}\right), \cos\left(\frac{\pi}{4}\right)\right)$$

Now if we take a point on $\mathbf{x_A}$, lets say $\mathbf{p_{A}} = (2,0,0)^T$ and we transform it I am expecting to obtain a point $\mathbf{p_{b}}$ as follows:

$$\mathbf{p_B} = \mathbf{q_{AB}}\otimes \mathbf{v_A} \otimes \mathbf{q^*_{AB}} = (0, -2, 0,0)^T$$

In the last formula I abused the notation of the vector as quaternion, apologies if it bothers you. However, for some fault in my reasoning, when I carry my computations I obtain that the point in the reference frame B is $\mathbf{p_B} = (0,2,0)$ as if the rotation had been clock-wise!

As a last remark, I am using the following notation for the transformation. $$\mathbf{v'} = \mathbf{q} \otimes \mathbf{v} \otimes \mathbf{q^*} = \mathbf{q}^+ \mathbf{q^*}^\otimes\mathbf{v}$$ with

$$\mathbf{q}^+ = \left(\begin{array}{cc} \eta \mathbf{I}_3 + \xi^\times & \xi \\ -\xi^T & \eta \end{array}\right)$$ $$\mathbf{q}^\oplus = \left(\begin{array}{cc} \eta \mathbf{I}_3 - \xi^\times & \xi \\ -\xi^T & \eta \end{array}\right)$$

where

$$v^\times = \left( \begin{array}{cc} 0 & -v_z & v_y \\ v_z & 0 & -v_x \\ -v_y & v_x &0 \end{array}\right)$$

Can anyone help me find the mistake in my reasoning?

Thank you

Andrea

$$\mathbf{v'} = \mathbf{q} \oplus \mathbf{v} \oplus \mathbf{q^*} = \mathbf{q}^+ \mathbf{q^*}^\oplus\mathbf{v}$$
It is actually the active rotation of a vector $\boldsymbol{v}$. Hence, in my example I am rotating the vector to a new vector that I wrongly called $\boldsymbol{v_B}$, but is still expressed in the reference frame $\boldsymbol{A}$, therefore it should be called $\boldsymbol{v'_A}$. The passive rotation of a vector is defined as:
$$\mathbf{v'} = \mathbf{q^*} \oplus \mathbf{v} \oplus \mathbf{q} = \mathbf{q^*}^+ \mathbf{q}^\oplus\mathbf{v}$$