This article is written for people seeking intuition on dual quaternions (and perhaps even complex numbers and quaternions) beyond what is offered by traditional texts. The standard way a dual quaternion is defined is by introducing a dual unit $\epsilon$ which satisfies $\epsilon\epsilon = 0$ and slapping a quaternion and a dual-scaled quaternion together. A whole ton of algebra follows and mechanically at least, everything checks out, as if by magic. At some point, the writer will point out how dual quaternions are isomorphic to Clifford algebras (or somesuch mumbo-jumbo pertaining to Lie algebras). If you’ve taken a course in abstract algebra and are intimately comfortable with the notion of homogeneous coordinate systems already, maybe such a treatise was more than adequate. Chances are though, the concept of dual quaternions (and likely quaternions as well) feels somewhat hollow, and you are left with a lingering suspicion that there is a better way of grasping matters. Geometric algebra is there (and I recommend you take a look), but personally, having an appreciation of both is still useful, and I don’t actually find quaternions or dual quaternions to be unduly difficult or an inferior formulation in any way. I can’t lay claim to having a perfect understanding of the subject, but I am documenting my understanding here in the hopes that it may point you, fellow mathematician (graphics programmer, AI researcher, masochist, or what have you), in the right direction.

## The goal

The ultimate goal is to have some sense for dealing with both quaternions:

and dual quaternions:

along with the ways they express rotation:

and both rotation and translation:

There’s a lot of “odd” things here that don’t seem very natural (the half angle, the “extra” dimension, the necessity of the conjugate operator, the mysterious $\epsilon$, etc), but hopefully after reading this, you’ll feel like these oddities are actually well-motivated and the only way it could be. Quick reader beware: this post may feel a little long-winded, mainly because I’m trying to make an effort of demonstrating what doesn’t work. For readers looking for more precise and direct exposition, I’ve included a number of links at the bottom. Perfect rigor is not a goal here because I do not want to assume that you’ve had any prior background in abstract algebra (although I hope you’ll be interested in it afterwards). I’m also going to try and stray away from formulae that may be more abstruse for most readers (Rodriguez rotation, Plücker coordinates, etc.). If those are familiar and comfortable topics, great! However, we’re going to try and loosely prove the results we want just the same without them.

## Back to complex numbers

Let’s review some things we know (and bear with me if it seems too slow). Complex numbers provide a means for us to elegantly describe rotation and scaling on a plane. Multiplication by the imaginary number $i$ is understood to perform a $90^\circ$ rotation. Multiplication by $i^2$ represents two such rotations, so $i^2 = -1$. Note first, there is an asymmetry in this algebra. Compared to a typical cartesian plane, the “action” described by a multiplication by $i$ compared to a real number is different. No amount of multiplication of a real numbers amongst each other can ever produce an imaginary number, but imaginary numbers manage to propel themselves from real units to imaginary numbers without much effort. Such asymmetry is actually fairly common in algebras, the study of which often amounts to defining various types of entities and the myriad ways they interact (taking care that they interact “nicely” with properties we know and love like associativity and the distribution law and such). Also, remember that not only can we multiply by $i$, we can add it too. We interpret this as a sort of “y” coordinate, and this should surprise you (if it hasn’t before). How can adding/subtracting units of $i$ be compatible with the rotation action of multiplication by $i$?

Herein lies the unreasonable efficacy of complex numbers. Algebraically, if we take a complex number like $2 + 5i$ and multiply by $i$, we get $(2 + 5i)i = 2i + 5i^2 = -5 + 2i$ which is our original number rotated $90^\circ$. This is “obvious” perhaps, but without fully appreciating how this is so, future attempts to generalize the concept to quaternions and dual quaternions will indubitably fail. For some clarity, we presume that addition is commutative (colloqially, it makes no difference if we go up and over, vs over and out). By the distributive law, multiplying by $i$ applies the rotation to both components of the number (in this case, $2$ and $5i$) leaving us with two rotated components, and we’re left with two components that summed up, resulting in the rotated form of the original number. Incidentally, thinking in terms of the action as defined on the components is sometimes more helpful (the vector representation of a complex number is illustrative, but perhaps not the most fundamental). Really, we just let $i$ function as a “y-coordinate” as an algebraic convenience. We could have left the vector in cartesian form $a\hat{x} + b\hat{y}$ and defined $i\hat{x} = \hat{y}$ and $i\hat{y} = -\hat{x}$ to get the same results, but this is redundant since replacing $\hat{x}$ with $1$ and $\hat{y}$ with $i$ produces the same effect.

This should feel pretty gentle so far. Another question to test your understanding is to consider how rotations of angles that aren’t right-angle multiples are defined. Why does the number system we defined so far permit, say, a $15^\circ$ rotation or a $\pi/9$ radian rotation? After all, multiplication by $i/2$ doesn’t give us half of a quarter turn (it shouldn’t because we’re scaling $i$ down by a real number). Intuitively, exponentiation of $i$ should result in fractional turns (or turns greater than a right angle) since this is a way to multiply $i$ by varying degrees. But what’s, say, $\sqrt{i}$ and how can we get such a quantity if we’ve only imposed that $i^2 = -1$? Easy. $\sqrt{i}\sqrt{i} = i$ so multiplying by the square root of $i$ must produce a $45^\circ$ rotation. Better yet, we can even represent $\sqrt{i}$ as a normal complex number (pretend we only care about the positive root) $1/\sqrt{2}(1 + i)$ which we recognize as a vector stabbing in the $45^\circ$ direction with length unity. Of course, we can whip out De Moivre’s Theorem here, but I’m trying to keep things tidy (avoiding transcendental functions). Try to think less about cosines and sines, and more about how from simple definitions and requirements (commutivity, distributive law, $i^2 = -1$), we can suss out everything we need.

Great, we have a notion of rotation now in two dimensions, so let’s go to three. This is where tons of people get tripped up because quaternions behave somwhat differently to complex numbers (at least superficially). For one thing, a general quaternion has three imaginary parts and one real part (as opposed to the “expected” two imaginary parts). Furthermore, the rotation formula involves a strange conjugation and rotates by a half-angle. What gives?

The first thing to recognize is that “going from two dimensions to three dimensions” is a somewhat misleading characterization of our transition. Instead, consider that we’ve gone from one axis of rotation to three axes of rotation! This alone should make the “extra” imaginary component less surprising. The other “weird” thing happening is that we want to describe rotations in 3D space… but we now have a 4-dimensional algebraic entity. Let’s see what happens if we try the “natural” thing of representing 3D space with entities of the form $a + bi + cj$ where $i^2 = -1$ and $j^2 = -1$ represents $90^\circ$ rotations. Suppose we let units of $j$ go “into” and “out of” the graph of the typical complex plane, so that multiplication by $i$ rotates about the $j$-axis (as before). We immediately run into a problem of deciding what axis $j$ should rotate a point about. The real axis? The $i$-axis? Something else? Unfortunately, there are an infinite number of choices because we need three axes of rotation in 3D-space, not two. What we really need, is a third “imaginary” unit that behaves similarly to the other two, all three of which together encode information about rotation.

Ergo, let’s add that fourth dimension. First, mentally visualize the real number line. Next, imagine that each imaginary unit $i$, $j$, and $k$ are all orthogonal to it (we are in 4D now and think of these imaginary planes as extensions to the real number line if you will). For every real number, each one defines something akin to the complex plane from before ($i^2 = j^2 = k^2 = -1$). To be a well-defined system, multiplication by $i$ needs to “work” not just when multiplying to a real number, but also to units of $i$, $j$, and $k$ as well. What should $ij$ be for example? Well, multiplication of a real number by $i$ rotates about an axis (or set of axes, remember we are in 4D) orthogonal to both the reals and the $i$-axis. It would be extremely odd for multiplication by $i$ to take $j$ into the reals or $i$ units, because subsequent multiplication would never “wrap back around” to the $j$ units. We need $i$ to be a pure rotation, so that won’t do, not to mention that the operation is no longer invertible. Similarly, $i$ shouldn’t scale $j$ by some real-valued amount since the reals already do that, and it seems unreasonable that the reals and the imaginary units of $i$ act the same in the $j$ dimension but differently elsewhere. Our only choice then, is that the action of multiplying $i$ onto $j$ produces $k$ units (we’ll choose positive $k$ by convention) so that $ij = k$. Multiplying both sides into $k$ gives $ijk = -1$ and applying $i$ to this gives $i^2jk = -i \Rightarrow jk = i$. So there we have it, all the definitions associated with the canonical quaternion basis units. This rhymes with the situation with the complex numbers, but is different in the sense that the action defined by multiplying each imaginary unit rotates not just the reals but the other imaginary units as well. This is a very important distinction that will come into play when appreciating the rotation formula later. Applying these definitions along with the usual rules of additive commutivity, associativity, and the distributive law gets us a well defined way of adding and multiplying quaternions together.

“Well, that’s all fine and dandy,” you might say, “but I’m interested in rotations in 3D, not 4D!” Very true, and herein lies the trickier bit to grasp. We need a way to express the effect of 4D quaternion multiplication in three-space. What would be great is if we could just read off the imaginary components directly. After all, they naturally correspond to three orthogonal axes with natural properties for component-wise vector summation. Should two quaternions with different real parts represent the same 3D point/vector though? Would such a system work at all? Let’s try to use our quaternion algebra to do a really simple task first, rotating the point $(1, 0, 0)$ about the $z$ axis $90^\circ$ (we should end up at $(0, 1, 0)$). First, let’s represent our point as a quaternion $0 + i + 0j + 0k = i$. We know we need this to end up at $j$ and as it turns out, multiplying by $k$ does exactly that which more or less mirrors our experience thus far with complex numbers (we don’t multiply by $j$ to rotate into $j$ because we are rotating from a different imaginary unit, not the reals). So far so good! Spoiler alert, though, this approach doesn’t work generally as we’ll see soon enough. Now let’s try something harder. Let’s rotate the point $(1, 0, 1)$ about the $z$ axis (we’re expecting $(0, 1, 1)$). Representing it as the quaternion $i + k$ and multiplying by $k$, we get $ki + kk = j - 1$. Ah, now we see the problem.

We wanted multiplication by $k$ to rotate us by the $z$ axis, but in actuality, this operation does multiple things, rotating not just units of $i$, but also $k$ ($j$ too although we didn’t see it in the example). As a brief recap, we’re looking for an operation that can express a rotation about the $z$ axis for all points. Let’s try to brute force something for all points in the $xz$-plane. We know that application of $k$ makes the following “movements”:

Our spider senses here should be tingling. A single application of $k$ is going to generate the wrong types of units, but two applications will always get us back to where we started. From our previous example, we want to keep the action of $k$ that brought $i$ to $j$, but don’t want the extra effect of bring $k$ to the reals. We have one trick up our sleeve though, which is the judicious use of left vs right multiplication. When we move from the reals to an imaginary unit and back, it makes no difference whether we use left or right multiplication. In contrast, rotating among the imaginary units will flip signs depending on whether we pre- or post-multiply. Ergo, we have a hope of finding a pair of quantities such that upon pre and post multiplication to the vector we wish to rotate, we can cancel out rotation we don’t care about, and preserve rotation we do care about.

This is where the conjugation operation $pqp^{-1}$ comes into play. Let’s choose our rotator $p$ to be of the form $a + b\mathbf{k}$ (again, focusing on just rotation about the $z$ axis) and take $p^{-1} = a - b\mathbf{k}$ to be the inverse (analogous to complex conjugates). We can enforce that $a^2 + b^2 = 1$ to ensure we aren’t changing the length of $q$, and intuitively, this makes sense because our operation will only have a single degree of freedom (two variables, one constraint). Applying the conjugation to $i$ gives:

In order to get the result we want, we require $a^2 = b^2$ and $2ab = 1$ which works if $a = b = 1/\sqrt{2}$. Notice how the inclusion of the reals and the sign flip allow us get a quantity we can cancel as much or as little as we like by choosing $a$ and $b$ along with a secondary amount we can control (in this case, pointing along $j$). We were able to do this by leveraging the anti-commutative aspects of the imaginary units compared to the reals. Let’s try doing the same computation to our point offset by a unit of $k$ (goal after rotation is $j + k$).

This is where something mindblowing happens. The same choice of $a$ and $b$ as before ($1/\sqrt{2}$) produces the desired rotation of $i + k$! If you follow the algebra closely, what we did was the $k$ component of the vector we were rotating moved into the reals and back again twice. That is, for our choice of $p$, we’ve arranged it so that application of the conjugation to any vector with a component along $k$ will preserve that $k$ provided that $a^2 + b^2 = 1$. Now, this resembles the pythagorean identity $\cos^2\theta + \sin^2\theta = 1$. The other term that shows up $2ab$ looks a lot like the sine-half angle formula $\sin{2\theta} = 2\sin{\theta}\cos{\theta}$. This leaves our last term $a^2 - b^2$ which looks a lot like the cosine-half angle formula $\cos{2\theta} = \cos^2{\theta} - \sin^2{\theta}$. In reality, this should be all too surprising since we’ve taken what amounted to a linear combination of $90^\circ$ rotations (some arbitrary rotation in 4-space) and applied them twice with a sign adjustment on the second application.

Recapping, we were seeking a simple operation that, applied to any imaginary vector representing a direction in 3-space, would perform a rotation about the $z$ axis. We needed to ensure that any $k$-component in the rotating vector needed to be preserved, and to do this, we leveraged the reals by applying two multiplications (moving to the reals and back). We still needed a rotation effect to linger, so we took advantage of combining pre and post multiplication along with a sign flip so that rotation of the imaginary components doesn’t cancel, but the rotations into and out of the reals does. What we ended up with was a conjugation for which all the half angle formulas popped out, which intuitively, is great because we’re doing two applications after all. Without going through the full derivation, it should make sense in a handwavey fashion that this reasoning applies equally well when rotating about a different axis, and due to the nice linear properties of our algebra, the general formula for rotation about an axis should be correct.

### Why did we go through all that trouble

Let’s talk about some properties of quaternion rotation. First, it’s extremely easy to describe the rotation of a vector about another one (in contrast, try writing the rotation matrix by hand). Applying the rotation matrix just relies on the standard rules of algebra. Also, we can compose multiple rotations with algebra just as well. Suppose we want to rotate $q$ by $p_1$ and $p_2$.

We have an identity $(\mathbf{p_2}\mathbf{p_1})^{-1} = \mathbf{p_1}^{-1}\mathbf{p_2}^{-1}$ so we can work out the product $p_2p_1$ in advance and take its inverse later. Thus, quaternion rotation is just as composable as rotation using matrices (in fact, we can derive a matrix representation of the conjugation operation without too much difficulty).

The real kicker is that because the application of quaternion rotation is done through purely linear algebraic manipulation, we can take derivatives of the rotated result $\mathbf{q}'$ with respect to changes in the rotation $\mathbf{p}$. This does not work with matrices element by element, because for a general rotation matrix, the elements are actually coupled to each other nonlinearly. This is why we can efficiently and accurately interpolate between quaternions (either linearly or spherically depending on the velocity desired).

Hopefully at this point, we’re ready to make the leap to dual quaternions. Like before, we want to develop a well-behaved algebra, but in this case, we want to extend quaternions to permit both rotations and translations. It’s not wrong to wonder why this is difficult, after all, most people are introduced to translations simply as component-wise addition of vectors. We could, if we wanted, proceed in this way with a bit of bookkeeping, remembering what quantities should be interpreted as translations, and what quantities should be rotations. Difficulty will ensue, however, if we wish to compress multiple transformations (both rotations and translations) together, since the operations don’t commute in general. If we chose to represent everything with matrices in projective space, this is possible but we would lose the nice compact representation we just developed with quaternions, as well as the ability to cleanly interpolate or differentiate. So, we need to extend our currently developed quaternion algebra to encode translations.

Let’s pretend first that we haven’t already seen the formulation of dual numbers and all that. Left to our own devices, we know that we want our “upgraded quaternion” to apply transformations via the same conjugation operator as before. That way, the transformations can compose via simple multiplication as before and we can reuse our rotation formulation as well. To separate the effect of a translation from that of a rotation, we’ll introduce a new unit called $\epsilon$ so that our upgraded quaternion has the form $\mathbf{p} + \epsilon\mathbf{q}$. Note that we aren’t so much “requiring” that this is the correct form. The introduction of a new unit $\epsilon$ imposes this form that now encompasses all possible linear combinations of units that make up our dual quaternion. Let’s consider how the conjugation operator behaves acting on identity (we’ll define the inverse based on the quaternion inverses as well as a sign flip on the dual element).

If instead of conjugating the identity, we conjugated a versor (purely imaginary quaternion) scaled by $\epsilon$, we’d get the following:

At this point, let’s make the following observation. If we let $\epsilon^2 = 0$, then the conjugation by a dual quaternion of an versor scaled by $\epsilon$ is just $\epsilon \mathbf{p}\mathbf{v}\mathbf{p}^{-1}$. This is precisely the rotation operator of the standard quaternion from the previous section. Conversely, the conjugation operator on the identity reduces down to $1 + \epsilon(\mathbf{p}\mathbf{q}^{-1} - \mathbf{p}^{-1}\mathbf{q})$. To proceed then, we need to consider the quantity $\mathbf{p}^{-1}\mathbf{q} - \mathbf{p}\mathbf{q}^{-1}$. If this could somehow represent translation, then we’d have both our bases covered. Expanding:

At this point, to “arrange” that we get a translation, let’s arbitrarily choose $p_r = 1$, $q_r = 0$ and $\mathbf{q_i}$ to point in some direction $\mathbf{d}$ and have unit length so that the expression above reduces to $2\mathbf{d}$. This corresponds to a motion in the direction $\mathbf{d}$ with a displacement of 2! This indicates that the conjugation of a dual quaternion of the form $1 + \frac{\epsilon}{2}\mathbf{d}$ performs a pure translation along $\mathbf{d}$. Meanwhile, because $\mathbf{p_i}$ drops out of the expression because $q_r = 0$, we can continue to use it to represent rotation.

To finalize things, we simply compose the two actions. Given a quaternion representing a rotation $\mathbf{q_r}$ and a vector of desired displacement $\mathbf{d}$ (both unit in length), we combine the effects in the only reasonable way (multiplication). We have associativity after all, because we have a cleanly defined algebra, so let’s use it!

Like our quaternion, this quantity has a well defined derivative (not developed here) and can thus be used for rigid transformations, unlike a matrix formulation (again with weird non-linear cross terms). Remember that when we are trying to transform a point, it now needs to be in the form $1 + \epsilon(p_x\mathbf{i} + p_y\mathbf{j} + p_z\mathbf{k})$ (refer to the development of the equation from the beginning of this section if you forget why).

## Review

We started with a new set of units $i$, $j$, and $k$ to encode rotations about 3 axes. Things needed to be different from our familiar complex numbers because we jumped from a single axis of rotation to three. This required an additional dimension to keep things clean (in the same way that we needed two dimensions to handle a single axis of rotation). The action of multiplication by each individual unit performed two effects: rotation into and out of the reals from that unit, and a rotation in units for the others in a manner that anti-commutes (commutes with a sign flip). Thus, encoding a rotation is done quadratically with a sign flip to cancel the effect we don’t want, and persist the effect we do want. This doubled the effect of the rotation, hence the presence of half-angles in our final formulae.

Moving to dual quaternions, we wanted to introduce a way of encoding translation by a vector that would not disrupt the mechanics of the conjugation operator. This way, we could in effect re-use the machinery of the quaternion while maintaining the nice algebraic property of associativity (which is what lets us compose successive transformations with multiplication). To separate the encoding of the translation, we introduced a new unit $\epsilon$. Because our conjugation operation produces quadratic terms, we simply impose that the dual unit has the property $\epsilon^2 = 0$ (in fancy terms, $\epsilon$ is nilpotent). We then performed the conjugation on a real number and a pure imaginary quaternion to see the effect. By choosing the non-dual and dual parts carefully, we could easily produce a pure rotation and a pure translation. Composing the two operations multiplicatively (again exploiting associativity), we were able to arrive at the final expression representing a combined rotation and translation.

Both quaternions and dual quaternions can be continuously mapped to each other so we can differentiate them which comes into play when implementing animation systems or simulations that rely on rigid motion. We didn’t develop any formulism in this regard, but hopefully, texts that define the spherical interpolation and quaternion/dual-quaternion derivatives will be more accessible. As a final takeaway, it’s worth stepping back and appreciating the efficacy of abstract algebra as a tool for encoding actions. Typically, the development of a new algebra stems from identifying a desired behavior, attempting to arrange for it to “be so,” and observing the fallout that results. To continue your studies, I’ve assembled a number of helpful papers and resources I’ve used below. Feel free to message or tweet your feedback on the article using the various social media links below. Thanks for reading and if you managed to get through the whole thing, give yourself a proverbial pat on the back.