# How to rotate unit vectors and unit quaternions by unit quaternions?

First of all, I might have to apologize for my half-knowledge and the noob-questions which are about to come, but here we go:

So, from what I've read/watched/heard, it appears to be like follows: Any given position vector $$\vec{p}$$ can be rotated by a unit quaternion $$q$$ like follows: $$\vec{p}' = q \cdot \vec{p} \cdot q^{-1}$$
That's true, isn't it?

My first question would be: Is this also true for normalized direction vectors, i.e. vectors which are not representing an arbitrary position but a direction and are of unit length? I am especially wondering if that trailing "normalizing"(?) $$q^{-1}$$ operation could be omitted if a was rotating a normalized vector.

Next question: How do I rotate another unit quaternion by a given unit quaternion? I am aware of that I have to multiply them and that the order matters (The rotation on the left will be applied before the operation on the right, is that true?). But I am wondering if I also have to do some kind of "$$q \cdot$$ and $$\cdot q^{-1}$$ sandwich" operation to rotate it correctly?

Follow-up question: Is the result of transforming (i.e. rotating) a unit quaterion by another unit quaternion also automatically a unit quaternion or do I have to normalize the result to get a unit quaternion?

Bonus question: Do you have any good resources for learning more about quaternion math?

• An amazing resource to visualize quaternion is this website by 3blue1brown. – Strichcoder Apr 17 at 20:21

There are many good and deep questions here, so I apologize that I only have time to give a few very terse answers. A complete set of answers, starting with the definition of the quaternions, for all of these questions would take the better part of a short text or monograph.

First, note that if $$q$$ is a unit quaternion then $$q^{-1} = q^*$$.

Second, yes. The rotation formula $$p \mapsto qpq^*$$ works for all quaternions $$p$$, hence in particular for unit quaternions.

Third, the multiplication by $$q^*$$ is not a normalization, it is the second part of a conjugation operation. To see that it is necessary, even in the case of unit vectors, it is enough to verify that mapping $$i \mapsto q i q^*$$, $$j \mapsto q j q^*$$, and $$k \mapsto q k q^*$$ leads to a parameterization of $$SO(3)$$ in terms of the quaternion coefficients, which corresponds to a proper rotation in $$\mathbb{R}^3$$, while omitting the conjugate does not.

Fourth, "How do I rotate another unit quaternion by a given unit quaternion?"-- this depends on what you mean by "rotate". The unit quaternions form a multiplicative group, so defining the map $$\phi_p\colon\mathbb{H}_U\rightarrow \mathbb{H}_U$$ (where $$\mathbb{H}_U$$ is the group of unit quaternions) by $$\phi_q(p) = qp$$ is akin to a rotation "by $$q$$" on $$S^3$$, but may not correspond to a proper rotation in $$\mathbb{R}^3$$. The conjugation map however $$p \mapsto qpq^*$$ will correspond to a proper rotation.

Fifth, yes. The unit quaternions are closed under multiplication.

Sixth, quaternions have a very long and confusing literature. It also depends on applications. Many guidance and navigation books have sections on quaternions, but these tend to over "vectorize" them (in fact, many aerospace books erroneously define them to be "four dimensional vectors", which they of course are, but that's not what makes them useful). A better example of the aerospace books is Markley and Crassidis Fundamentals of Spacecraft Attitude Determination and Control. I know there are some books on using quaternions for computer graphics, but I don't work in that field and wouldn't be able to confidently recommend one. A classic mathematical text is Rotations, Quaternions, and Double Groups by Altmann. I haven't read it, but Conway's On Quaternions and Octonions looks interesting. During my first study of quaternions in the context of rotation, I found that learning a little bit about Lie groups, especially $$SO(3)$$ and $$SU(2)$$ was invaluable so you might want to check out some basic books there. I have Lie Groups, Lie Algebras, and Representations: An Elementary Introduction by Hall and this is an easy, quite gentle introduction.