# Calculating a quaternion that represents a given rotation

This is the first time I'm attempting to do a quaternion and I am not quite getting the concept. This is part of a 3 calculation homework question

The initial question is

1. Given a 3-D point at position $(0, 1, 0)$. Provide the matrix for a $90$ degree rotation around the $x$-axis. Determine the point that results from performing that rotation on the original point. Next provide the matrix for a $45$ degree rotation around the $y$-axis. Determine the result from performing the $y$-rotation on the point that resulted from the previous rotation. Finally provide the matrix for a $180$ degree rotation around the $z$-axis. Determine the result from performing the $z$-rotation on the point that resulted from the previous rotation. Because no translations are involved, you can use $3 \times 3$ matrix math for your calculations.

I've done these with matrix mult but the next part is quaternions:

Using quaternions, perform the same three rotations on the same original point in problem 4. Show the quaternion and its conjugate used for each rotation and the quaternion that results after using that quaternion to perform the rotation.

From what I understand... in order to do this I need to calculate the quaternion and the conjugate of it as well. I've never done this before but this is how I've started. I understand they have a basic structure of $q = w + xi + yj + zk$.

So for the first question I think what I'm supposed to do is the following: $$q = \cos\left(\tfrac{1}{2} \cdot 90^{\circ}\right) + i\sin\left(0 \cdot \tfrac{1}{2} \cdot 90^{\circ}\right) + j\sin\left(1 \cdot \tfrac{1}{2} \cdot 90^{\circ}\right) + k\sin\left(0 \cdot \tfrac{1}{2} \cdot 90^{\circ}\right)$$

which would give me

$$q = .7071 + .7071 j .$$

From there I don't really understand what to do though. What is that number supposed to be? What does it represent? And how do I take it to the next step?

You're on the right track: If we think of $\Bbb R^3$ as the set of imaginary quaternions, that is, as $\langle {\bf i}, {\bf j}, {\bf k} \rangle$, then we can write any rotation as the (linear) map $C_{\bf q} : \Bbb R^3 \to \Bbb R^3$ defined by $$C_{\bf q} : {\bf x} \mapsto {\bf q} {\bf x} \bar{\bf q}$$ for some unit quaternion $\bf q$.$^*$ If one takes the quaternion you've computed, namely, ${\bf q} := \tfrac{1}{\sqrt{2}} (1 + {\bf j})$ and writes out the matrix for $C_{\bf q}$, it should coincide with the first linear transformation you computed above.
The quantity $\bf q$ is simply a unit quaternion (so, we can think of it as being on the $3$-sphere $\Bbb S^3 \subset \Bbb H \cong \Bbb R^4$) that encodes the rotation. It follows immediately from the definition that $C_{\bf q} = C_{-\bf q}$, so there is some redundancy in the representation of rotations as unit quaternions, but it turns out that this is the only redundancy, that is, $C_{\bf q} = C_{{\bf q}'}$ iff ${\bf q}' = \pm {\bf q}$. So, the map ${\bf q} \mapsto C_{\bf q}$ that maps a quaternion to its rotation is a $2$-fold cover $\Bbb S^3 \to SO(3)$. (Thus, we can identify the group of unit quaternions, which we sometimes denote $SU(2)$, is the spin group Spin(3).) The fact that this cover is $2$-fold, that is, that each rotation is represented by exactly two quaternions, is basically responsible for the factors of $\frac{1}{2}$ that appear in the angle arguments.
$^*$Note that this requires a general fact that I recommend you check, namely, that for any ${\bf x} \in \Bbb R^3$, $C_{\bf q}({\bf x})$ is actually an imaginary quaternion.
• Feel free to ignore the comments about "$2$-fold cover," etc., which are basically color commentary. A quaternion $\bf q$ is a unit quaternion iff $||{\bf q}||^2 = 1$, and it's often convenient to rewrite this as ${\bf q}\bar{\bf q} = 1$. And yes, to compute the conjugate of a quaternion, just change the sign of the coefficients of the imaginary (${\bf i}, {\bf j}, {\bf k}$) terms. And yes, $\overline{\frac{1}{\sqrt{2}}(1 + {\bf j})} = \frac{1}{\sqrt{2}}(1 - {\bf j})$. – Travis Apr 17 '16 at 15:18
• The rotations determined by $\bf q$ and $\bar {\bf q}$ are in general not the same---they are rotations about the same axis, but in opposite directions. It is true, though, that for any imaginary quaternion ${\bf q}'$, we have $\bar{\bf q}' = -{\bf q}$; if ${\bf q}'$ is imaginary, then $C_{{\bf q}'}$ is a $180^{\circ}$ rotation about the corresponding axis. – Travis Apr 17 '16 at 15:21
• It's a good exercise to verify that if you write ${\bf q}{\bf q}'$ in terms of the components $a, b, c, d$ of $a + b {\bf i} + c {\bf j} + d {\bf k}$, then you get $a^2 + b^2 + c^2 + d^2$, which is the usual form for the length of the vector $(a, b, c, d) \in \Bbb R^4$. I'm not sure what went wrong in your computation of ${\bf q}{\bf q}'$ for your $\bf q$, but it looks like you forgot half of the terms. Indeed, ${\bf q}{\bf q}'$ is always real! – Travis Apr 17 '16 at 15:57