Dual Quaternions

for transformation of spatial information


| NN Top | Introduction | Newton's Method | Fuzzy Logic NNs | & training rule | Twist-and-Bend | Space Representing NNs | Dual Quaternions | Algebroids | Robots |

This discussion of Dual Quaternion math is taken from others, not original. Still it is a good exercise to write it down for myself, and perhaps others will find it useful as an accessible and practical introduction to them.

The dual quaternion concept enables compact, efficient geometrical rotation+translation (or translation+rotation) transformations of relative spatial location information, encapsulating the link transformation calculations used in Space Representing Neural Networks. Here I derive them from complex numbers to quaternions to dual quaternions, showing equations by which a spatial location encoded from one "camera" position and orientation can be transformed so it is seen from another camera position and orientation, that is, not by a rigid body transform, but by a rigid perspective transform, comprising translation composed with rotation. A hierarchy of such transformations, carried out inward across the nodes of a tree of perspective-holding positions, can combine sensory information from many peripheral sources into a spatial representation of the entire scene held at the center or root of the tree, and the reverse transformations can distribute actuator signals to their recipient actuator nodes, similarly, by spatial encodings mapped from central to peripheral.

The fundamental concepts and properties of quaternions, dual numbers, dual quaternions, and rotation/translation with dual quaternions as presented here came from various sources but especially Iowa State University Professor Yan Bin Jia's paper Dual Quaternions. Thanks are due to him and the chain of predecessors, especially Hamilton and Clifford.

Quaternions

First, quaternions (Hamilton's set, ℍ).

Oh I like history, and conceptual history best of all, so let me tell a little of the story.

Hamilton was so excited by discovering quaternions that he carved graffiti on the bridge where he was walking as a memorial to the time and place that they came to mind; a plaque is still there. (One wonders what was the experience of his wife, on that walk with him.)

For months his sons had asked him, Can you multiply triples yet, Father?

Multiplying single numbers, \(a\times b = a\cdot b = ab\), we learned in elementary school. Late in high school, maybe, we learned doubles, called complex numbers, as in \((A+i\ a)(B+i\ b) = (AB - ab+i\ (aB+Ab)\) with this impossible symbolic trick, \(i^2=-1\), which works if you think \(i\) is a 90-degree rotation in a plane, so that doing it twice gets you from \((1,0)\) to \((-1,0)\).

Someone said, you lost me already, Tom. So let's express it as a Sum Table:
\((A+i\ a)(B+i\ b) =\)
  \(\large \sum \cdot\)      \(B\)    \(i\ b\)
   \(A\) \(\ \ AB\)  \(\ i\ Ab\) 
   \(i\ a\) \(i\ aB \)  \(-bB\) 
(I like Sum Tables better than FOIL, just different ways to do the same thing. I don't have to be quite so smart, if I just use Sum Tables instead.)

I think you have it now.

Hamilton was blocked on triples. Triples being three dimensional, that is, spatial information, triples are a significant generalization of our concept of 2-D, \(a+i\ b\), complex numbers. Vectors with our \((x,y,z)\) "homogeneous coordinates" came later, after Hamilton spent his life struggling along in that direction, as it turns out, carrying the entire world on his back.

Suppose you have an idea and instead of \(i^2=-1\) you said \(i^2=j^2=-1\) but \(i\ne j\), where does that get you? Could you let \(j=-i\), for example, so \(ji=ij=1\) ? Think of it as different directions around the unit circle in the imaginary plane. But you don't need a \(j\) for that since you could just use \(-i\). So your idea works fine, but it doesn't actually expand the Universe of Mathematics. This is the kind of thinking. It's actually fun to try different values like \(1,0,-1,..\) for \(i,j,i^2,j^2, ij\), and \(ji\), etc., and see if you get something useful. That's what Hamilton, and later Clifford did, and why should they have all the fun?
Hamilton fully explored the possibilities and while walking on this bridge he finally realized we need three imaginary directions, plus the real numbers (if \(i^2=-1\) we are stuck with a real number, \(-1\), in the system). So his trick was to use four numbers, not three, for multiplying triples. He called them "quaternions", for "four".

I'll use \(q, p\) as generic names for quaternions, and write them alternatively:

These are the same idea in different forms.

(Quaternions did, incidentally, inspire vector and matrix algebra and geometry which we all learn in college algebra and higher math today. Further along this path in work called "Geometric Algebra" by that other 19th century genius, W. K. Clifford, one multiplies three directed line segments \((1,0,0), (0,1,0),\) and \((0,0,1)\) by \(i=\sqrt{-1}\), and calls the three by the names \(e_1, e_2, e_3\), which generalizes and simplifies Hamilton's quaternionic triple-imaginaries. Go explore!)

So Hamilton imagined three separate imaginary numbers, which he called \(i,j,k\) and gave them two axioms, (1) that they square to \(-1\), and (2) that multiplication of any two different ones is a "rotation" (really, a screw movement) starting from the first of the pair going toward the second, but actually reaching the third, following around the triangle from \(i\) to \(j\) to \(k\) to \(i\) again, etc. That is:

\(i^2=j^2=k^2=-1,\ \ \ \) and \(\ \ \ ij=k,\ \ \ jk=i,\ \ \ ki=j\).
which implies (pre-multiplying the above):
\(iij=ik=-j\), \(\ \ \ jjk=ji=-k\), \(\ \ \ kki=kj=-i\ \).

This idea captures screw-like rotations where a turn from one to another gives a movement perpendicular to the rotation. One of each gives you the third, and if you turn in the opposite direction between them then the perpendicular movement also goes in the opposite direction. Different orders and relabellings amount to the same. But you still need the real numbers in this space with -1 being a real number. Since imaginary products are anti-commutative (ij = -ji, &c.) let me throw in a last axiomatic factoid here and remind you that real number products are commutative (ab=ba), which will include reals with imaginaries (aiq=iaq=iqa which you could derive from ia=ai).

So far it seems potentially useful.

Let's define quaternions and conjugates \(q^*\), then products \(pq,p\cdot q, p\times q\), then things that depend on products, like norm \(|q|\) and inverse \(q^{-1}\). Let:

\(\vec q ≜ iq_1 + jq_2 + kq_3\) (not named. "Tri-Imaginary Vector"? Or add 0 to get a Pure Quaternion.)

\(q ≜ q_0 + \vec q = q_0 + iq_1 + jq_2 + kq_3\) ("Quaternion)

\(q^* ≜ q_0 - \vec q = q_0 - iq_1 - jq_2 - kq_3\) ("Conjugate" means minus the vector part.)

Uh-oh, now we have to multiply triples. Woohoo! In my personal opinion, this is discussed badly and without simplicity and insight wherever I've read it, so let this be my contribution to knowledge for today. We will do the simplest case, \(qq^*\), math here, discussion below.

\(qq^*\ \ =\ \ \)
\(\large \sum \cdot\ \)     \(1\ q_0\)       \(\ \ -i\ q_1\)       \(\ \ -j\ q_2\)       \(\ \ -k\ q_3\)  
\(1\ q_0\)   \(\ \ \ q_0 q_0\)   \(\ \ \ -i\ q_0 q_1\)   \(\ \ \ -j\ q_0 q_2\)   \(\ \ \ -k\ q_0 q_3\)
\(i\ q_1\)   \(\ i\ q_1q_0\)   \(\ \ \ \ \ \ \ \ \ q_1 q_1\)   \(\ \ \ \ \ \ k\ q_1 q_2\)   \(\ \ \ -j\ q_1 q_3\)
\(j\ q_2\)   \(\ j\ q_2 q_0\)   \(\ \ \ -k\ q_2 q_1\)   \(\ \ \ \ \ \ \ \ \ q_2 q_2\)   \(\ \ \ \ \ \ i\ q_2 q_3\)
\(k\ q_3\)   \(\ k\ q_3 q_0\)   \(\ \ \ \ \ \ j\ q_3 q_1\)   \(\ \ \ -i\ q_3 q_2\)   \(\ \ \ \ \ \ \ \ \ q_3 q_3\)
\( =\ \ \) \(\ \ q_0^2\ \ + \) \( (q_1^2 + q_2^2 + q_3^2)\ \ + \) \(\ \ q_0(\vec q) + q_0(-\vec q)\ \ + \) \( \ i\ q_2q_3 - i\ q_3q_2 + j\ q_3q_1 - j\ q_1q_3 + k\ q_1q_2 -k\ q_2q_1\ \ \)
├─┤ ├──────┤ ├──────┤ ├────────────────────┤
\(q_0^2\) \(\vec q \cdot \vec q \) \(\ \ \ q_0(\vec q) - q_0(\vec q) \) \(\vec q \times \vec q \)
├─────────┤ ├──────┤ ├────────────────────┤
\( q \cdot q \) \( 0 \) \( 0 \)

\( =\ \ \) \( q \cdot q \ \ = \ \ q^*q\)

There are several kinds of multiplication there.

Apparently I'm being a little outrageous, claiming that \(\vec q \times \vec q\) is actually a name for the leftover in the Sum Table for a Tri-Imaginary Vector product. Here, remove the diagonal (\(q_0^2\) and \(|\vec q|^2\)) (and cancel the rest of the top row \(-q_0\vec q\) and first column \(q_0\vec q\)). "What's left" is a better definition of vector \(\times\) ("Cross Product") than the official one (as \(\vec q\times \vec q ≜ |\vec q||\vec q|\sin(\theta)\)), since it is actually just the imaginary, which is to say the off-diagonal, parts of a product of vectors.

In the present case of \(qq^*\) all the components of \(\vec q \times \vec q\) cancel, so \(\vec q \times \vec q = 0\). This can also be seen through the official definition of \(\times\) namely \(\vec q\times\vec q ≜ |q||q|\)sin\((\theta)\) which is 0 because the angle \(\theta\) between \(\vec q\) and \(\vec q\) must be 0 and \(\sin(0) = 0\).)

So, yes, \(qq^*=q\cdot q = q^*q\).

That's it; we have now figured out \(p_0q_0,\ p_0\vec q,\ p\cdot q,\ p\times q,\) and \(pq\), all kinds of products, which are just different subsets of all the products in the Sum Table. (A maybe simpler rediscussion of this is here, if you like.)

Now, we can define quaternion ideas that depend on products: the norm, the inverse, and the conjugate products.

\(|q| ≜ \sqrt{qq^*}\ \ \ \ \ \) ("Norm")

\(qq^* = |q|^2\) \((q)(q^*)(|q|^{-2}) = 1 \) \(q^{-1} = \large \frac{q^{*}}{|q|^2}\ \ \ \ \ \) ("Inverse").

If \(|q|=1, q^{-1}=q^*\ \ \ \ \ \) (For unit quaternions, inverse = conjugate).

\((pq)^* = q^*p^*\) because as read off a Sum Table for a product of vectors:
\(\ \ \ \ \ \ \ \ \ \ \ \ \ (pq)^* = p_0 q_0 + \vec p\cdot \vec q - [ p_0 \vec q + q_0 \vec p + \vec p \times \vec q]\) and
\(\begin{align*} \ \ \ \ \ \ \ \ \ \ \ \ \ \ q^*p^* &= (q_0,-\vec q)(p_0,-\vec p) \\ &= p_0 q_0 + \vec q\cdot \vec p - p_0 \vec q - q_0 \vec p - (-\vec q \times \vec p) \end{align*} \) which are the same, given that \(p\cdot q = q\cdot p\), and \(p\times q = -q\times p\).

\(p\times q = -q\times p\) because when you multiply different imaginaries in the opposite order, you get the negative of the result, as in \(ij=-ji\) etc. That puts minuses in the Sum Table throughout the cross-product section, because although all the cells are multiplied in the opposite order, it is all and only the cross-product section cells where the imaginaries multiplied are different, so those get a minus when you reverse the order of the product.

(Now, did you have to memorize that? Or can you figure it out by looking at the table and remembering \(ij=k, jk=i, ki=j\)? That's all I need to do.)

When we use quaternions for rotation, we actually work with unit quaternions. That makes sense because if they were bigger than 1, multiplying by them would expand or shrink things. To keep things fixed in size, we multiply not by 1 but by something the same size as 1.

For translation, and for points in space, we can swap back to 3D space, or stay in quaternion space while encoding them as pure quaternions. Pure means \(i,j,k\) components only. These can be any magnitude as a whole, but the real component is zero, so we can add and subtract their \(i,j,k\) components separately, just like normal vector addition and subtraction.

Also, typically, we both pre-multiply and post-multiply the thing we are working on, in order to do rotations or reflections. We saw that if \(p\) is a unit quaternion, then \(p^{-1}=p^*\). So \(pvp^*=pvp^{-1}\) is a bit like doing nothing, since \(pp^{-1}=1\). But side effects happen on both sides of \(v\) when you pre- and post-multiply by \(p\) and \(p^{-1}\), and as it turns out those side effects turn into tidy sweet rotations, which for me is the whole entire point of quaternions.

Rotation with Quaternions

Unit quaternions both represent and implement rotation around an axis.

The representation encodes an axis and an angle of rotation in the four components of a quaternion, say \(p\). The implementation is by pre- AND post-multiplying what we want to rotate, call it \(v\), with our quaternion \(p\) and its complement / inverse \(p^{-1}=p^*\), as \(pvp^*\).

How and why it is that doing this double multiplication of quaternions actually carries out a tidy rotation operation remains a bit of a mystery. Jia's paper does this with an example, but it's not a general proof.

Two intuitions might help.

First, two reflections can make a rotation. Look at yourself in a mirror, your hair is on the wrong side as compared with how other people see you. Look at yourself in a mirror itself in a mirror, and you see yourself the way others see you. Freaky. The freckle on my nose is on the other side! Because two reflections give a rotation, so you don't see your reflection, you see your rotation. See the difference?

Second, here's a possibly wrong, but for me helpful, intuition. Now the rotation implemented by \(p\) is around a certain axis, \(\hat u\), and the rotation implemented by \(p^{-1}\) is the reverse rotation, taken by going the same angle but around the exact opposite axis, \(-\hat u\). (Think this through using the \(i,j,k\) rules, and then you'll have it.) Then doing a pre-multiplication and post-multiplication together of the thing we are rotating, by \(p\) and by \(p^{-1}\) will, whatever it does outside of nothing, or returning 1 to 1, will double the angle rotated through, since it does it twice, once around \(\hat u\) and once around \(-\hat u\). For this reason we use \(\frac{\theta}{2}\) instead of \(\theta\) in the equations below.

I don't think this has fully explained quaternions as rotations, but it's getting close.

Time to get specific: Representation.

First, construct a unit vector \(\hat u = i\ u_1+j\ u_2+k\ u_3\) (so \(|\hat u|^2=1\), which we can do by dividing any vector \(u\) by its magnitude, since \(u/|u|=\hat u\) has length \(1\), unless \(u = 0\)).

Then, notice \(cos^2(\frac{\theta}{2}) + sin^2(\frac{\theta}{2}) = 1\). This means we can put \(cos(\frac{\theta}{2})\) in the real part, and can scale down \(\hat u\) by \(sin(\frac{\theta}{2})\) (so its magnitude is \(sin(\frac{\theta}{2})\)), and then the magnitudes of the real and vector parts will each square and jointly sum to 1, so the whole quaternion is still a unit quaternion. (Remember "Norm" above: the norm is the squared length, and don't forget Pythagoras, since the sides are all perpendicular, the sum of squares is the square of the diagonal, which itself is the sum of the perpendicular edge vectors. It works.)

Combining \(\hat u, \cos(\frac{\theta}{2}), \sin(\frac{\theta}{2})\), we create another unit quaternion \(q\) thus:

\(q=cos(\frac{\theta}{2}) + \hat u\) sin\((\frac{\theta}{2}) = cos(\frac{\theta}{2}) + i\ u_1\sin(\frac{\theta}{2}) + j\ u_2\sin(\frac{\theta}{2}) + k\ u_3\sin(\frac{\theta}{2}) \).

That's the representation: \(\hat u\) and \(\theta\), bundled up like so in a unit quaternion.

Next: Implementation.

By God's fiat, or Jia's, Clifford's, or Hamilton's (because I don't understand why), any vector \(v\) can be rotated \(\theta\) around the axis \(\hat u\) by the equation:

\(v' = qvq^*\)
This is nothing but the Sum Table product above, but twice, so I'm not going to draw it out for you. It might be easier to just write the program.

So I did and discovered some finicky points, and I don't see where anyone mentions this but it won't work without this: To make a 3D point like \((p_x,p_y,p_z)\) into a quaternion, prepend a real number 0 and make the rest imaginaries. So \(v = (0, p_xi, p_yj, p_zk)\). The real 3D vector then becomes a pure quaternion.

An Example

So for example a 90-degree rotation of an \(x=1\) point, \(p=(1,0,0)\), around the y axis \(u=(0,1,0)\), is expected to come out to \(z=-1\) or \(p'=(0,0,-1)\). In quaternion rotation operations, this is accomplished as follows.

That is:
$$\begin{align} q &=\cos(\frac{\pi}{4}) + \sin(\frac{\pi}{4})(0i+1j+0k) &= \frac{\sqrt{2}}{2}+ \frac{\sqrt{2}}{2}j) \\ q^*&=\cos(\frac{\pi}{4}) - \sin(\frac{\pi}{4})(0i+1j+0k) &= \frac{\sqrt{2}}{2}-\frac{\sqrt{2}}{2}j) \\ \end{align}$$
Then:
\(qv=\)
  \(\large \sum \cdot\)     0     1i     0j     0k  
   \(\frac{\sqrt{2}}{2}\)    \(0\)  \(\frac{\sqrt{2}}{2}i\)  \(0\)  \(0\)
   0    \(0\)    \(0\)  \(0\)  \(0\) 
\(\frac{\sqrt{2}}{2}j\)       \(0\)   \(\frac{\sqrt{2}}{2}ji\)  \(0\)   \(0\) 
   0    \(0\)  \(0\)  \(0\)  \(0\) 
\(= \frac{\sqrt{2}}{2}(i-k)\)

I used \(ji=-k\). Notice that \(\frac{\sqrt{2}}{2} * \frac{\sqrt{2}}{2} = \frac{2}{4} = \frac{1}{2}\). Then:

\((qv)q^*=\)
  \(\large \sum \cdot\)   \(\frac{\sqrt{2}}{2}\)   \(0i\)   \(-\frac{\sqrt{2}}{2}j\)   \(0k\)  
0 \(0\)\(0\)\(0\) \(0\)
\(\frac{\sqrt{2}}{2}i\) \(\frac{i}{2}\) \(0\) \(-\frac{k}{2}\) \(0\)
\(0j\) \(0\)\(0\)\(0\) \(0\)
\(-\frac{\sqrt{2}}{2}k\) \(-\frac{k}{2}\) \(0\) \(-\frac{i}{2}\) \(0\)
\(= -k = 0 + 0i + 0j - 1k\)

Conveniently the real part remains zero, though that seems to be an artefact of our example's coordinates which don't happen to yield \(i^2,j^2\) or \(k^2\) anywhere in the products. Maybe that's a benefit of doing two multiplications, if the real parts appear and then drop out again: do they? Here, at least, we can now, without loss of information, pull out, or consider the whole vector to be, just its pure quaternion part, and finally swap out the i,j,k coordinates for the x,y,z coordinates. Then we see that indeed \(qvq^*\) yields (0,0,-1) as expected.

To see that this is two reflections, we might have to draw out all three \(v, qv\), and \(qvq^*\). Sorry I'm not good for graphics at the moment, but indeed \(qv_{R^3} = (s,0,-s)\) is on the 45 degree line halfway between (1,0,0) and (0,0,-1). Unexpectedly it is no kind of reflection, however. It's magnitude is also 1; it is a partial rotation along the unit circle in the \(x,z\) plane, and not on the line between the endpoints as would be expected if it were an actual reflection. So perhaps the discusson of quaternion rotation is metaphorical rather than literal. Or perhaps we only get a guarantee that the real part goes back to zero after the second multiplication, I'm still struggling with it, but now at least I've persuaded myself that the right thing happens.

Incidentally the Wikipedia discussion of this using \(p=i+j+k\) and angle \(\theta=2\pi/3\) (scroll down to "Example conjugation operation") is a nice generalization of this example, and almost as clear.

Okay, got it? Can you do it? You should be able to write programs to do this now.

Sequence of Rotations

A sequence of two rotations first \(q\), followed by a similarly constructed unit quaternion, say, \(p\), is accomplished by
\(v'' = p(qvq^*)p^* = pqvq^*p^* = (pq)v(pq)^*\)
This extends to any number of rotations, and conveniently allows for pre-multiplication of the sequence of rotations.

Best of all, as we see, we get calculation-free inverses by simply changing the signs on the imaginary parts, since \(q^{-1}=q^*\) for unit quaternions.

The unit-quaternion-rotation intuition is that \(qq^* = 1\), so whatever \(q\) does, \(q^*\) undoes it, except that by combining with \(v\) each leaves a half rotation of \(\theta\) around \(\hat u\), so that after both apply, \(v\) is a full \(\theta\) rotated around the original \(\hat u\). If each multiplication implements a geometrical reflection, since a rotation can be a composition of two reflections, additive reflections done twice by an angle \(\large \frac{\theta}{2}\) would produce a rotation by \( \theta\).

You are now fully introduced to Quaternions including their primary purpose of 3D rotations. To go further, you might be interested in the following.

Quaternion Translation (and Rotation)

Quaternions are overkill but fine for translation: Let \(u = dp\) where \(p\) is a unit pure quaternion (so \(p_0=0\) and \(p_1^2+p_2^2+p_3^2 = 1\)), a.k.a. a "direction". Scaling \(p\) by a "distance", \(d\), leaves the real part still zero, so we still have a pure quaternion, \(dp=(0,dp_1,dp_2,dp_3)\); then a point \(\hat v=(v_1,v_2,v_3)\) formed into a pure quaternion \(v=(0,\hat v) = 0+i\ v_1+j\ v_2+k\ v_3\), can be translated to a new position \(v'\) by
\(v' = v + u = v + rp = 0 + i(v_1+dp_1) + j(v_2+dp_2) + k(v_3+dp_3)\)
which is simply \(v\) translated distance \(d\) in the direction \(p\). Again, the real components all stay zero in this pure quaternion scale-and-sum operation, so \(v_0=v'_0=p_0=rp_0 = 0\).

How about rotation with translation (shift)?

Let \(v\) be any point in 3D space converted into a pure quaternion \(v = 0+i\ v_1+j\ v_2+k\ v_3\) ("point").
Let \(d\) be a scalar ("distance").
Let \(p= 0 + i\ p_1 + j\ p_2 + k\ p_3\) be a unit pure quaternion, that is \(p_0=0\) and \(|p|=1\) ("direction").
Let \(t\) be a pure quaternion \(t = dp = 0 + d\vec p = (0,dp_1,dp_2,dp_3) = 0 + i\ dp_1 + j\ dp_2 + k\ dp_3\) with \(|\vec p|=1\) ("translation").
As above let \(\hat u= 0 + i\ u_1 + j\ u_2 + k\ u_3\) be a unit pure quaternion, that is \(u_0=0\) and \(|\hat u|=1\) ("rotation axis")
As above let \(q\) be a unit quaternion encoding a rotation \(\theta\) around the axis \(\hat u\), that is,
\(\ \ \ \ \ \ \ \ q=cos(\frac{\theta}{2}) + \hat u\) sin\((\frac{\theta}{2}) = cos(\frac{\theta}{2}) + i\ u_1sin(\frac{\theta}{2}) + j\ u_2sin(\frac{\theta}{2}) + k\ u_3sin(\frac{\theta}{2}) \)
(Norms \(|v|\) and \(|t|=d\) can be any finite size.)

Then you can calculate a translation followed by a rotation like this:

\(v' = q(v+t)q^*\)

or a rotation followed by a translation like this

\(v' = qvq^* + t\)

That's it. You can do it all now. One layer at a time.

But if you liked the benefits of quaternion pre-multiplication, which lets you compose any number of rotation operations by pre-multiplying a bunch of them together (as we did above for just \(p\) and \(q\)), then you might also like those same benefits for composing any number of rotations AND translations together across a bunch of layers, which is what you get with Dual Quaternions. Then from a single start point you can move an object or a camera to the endpoint of a whole trajectory of moves by composing all the steps which got you there. Once. It could be convenient, like, to save way-points along the way, and then you don't have to reconstruct every step to get somewhere quickly. If that floats your boat, let's see about Dual Quaternions.

To get to Dual Quaternions, we have to understand Dual Numbers first, which is quite the weird idea.

Dual Numbers

Did you notice above I mentioned imaginable dimensions beyond just \(i\) which square to 1, 0, and -1? I was sneaking in the idea of dual numbers.

A dual number \(d=d_0+\epsilon d_1\) is a bit like a complex number in that it has a real component \(d_0\) and a non-real component \(\epsilon d_1\), but unlike the impossible-but-useful definition of \(i=\sqrt{-1}\), this \(\epsilon\) is defined as \(0 \ne \epsilon=\sqrt{0}\) or \(\epsilon^2=0\), which seems to contradict \(\epsilon \ne 0\)! Impossible! (But useful!)

To stretch our minds, imagine a space of \(l+m+n\) dimensions with \(l, m,\) and \(n\) distinct basis vectors that square to \(1, -1\), and \(0\), respectively. I only mention what some (like Clifford) have explored systematically, but for instance, for dual quaternions, \(l+m+n = 1+3+1\) or \(1+3+4\), depending how you count the products of imaginaries with \(\epsilon\).
The point of dual numbers is to simplify multiplication by eliminating higher powers. Addition is normal component-wise sum (so \(d + g = (d_0+g_0) + \epsilon(d_1 + g_1)\)), and multiplication is also normal (Sum Tables work here too), but because \(\epsilon^2=0\), dual number multiplication yields zero for any component containing \(\epsilon^2\). For example, using the FOIL (first, outer, inner, last) rule to expand a product of dual numbers:
\((a + \epsilon b)(c + \epsilon d) = ac + \epsilon(ad + bc) + \epsilon^2bd = ac + \epsilon(ad+bc) + 0 = ac + \epsilon(ad+bc).\)
and
\(d^n = (d_0+\epsilon d_1)^n = d_0^n + n d_0^{n-1} d_1\epsilon \)
which are only the first two terms of the general formula, the so-called binomial expansion, of \(d^n\):
\(\begin{align*} d^n &= (d_0+\epsilon d_1)^n \\ &= \sum_{k=0}^n \binom{n}{k}d_0^{n-k}d_1^{k}\epsilon^{k} \end{align*}\)
because after \(k=1\), the rest are zeroes since they include a factor \(\epsilon^2\).

Duals are cool because for polynomials (in the real part) they contain their own derivative (in the dual part):

\(P(d) = P(d_0 + \epsilon d_1) = P(d_0) + \epsilon d_1 P'(d_0)\)
The Dual Inverse isa

\( d^{-1} = d_0^{-1} (1-\epsilon d_1 a^{-1})\ \ \ \ \ \)

Dual dot products and cross products require vectors of dual numbers. Let \( \vec d = (\bar d_1,\bar d_2,\bar d_3)\) with each \(\bar d_i\) a dual number, as also \(\bar d\). Then:

\( \bar d\vec d ≜ (\bar d\otimes \bar d_1,\bar d\otimes \bar d_2,\bar d\otimes \bar d_3)\). (Dual-Number-Dual-Vector product)

Let also \( \vec e = (\bar e_1,\bar e_2,\bar e_3)\), with \(e_i\) all dual numbers. Then:

\(\vec d \cdot \vec e ≜ \bar d_1\otimes\bar e_1 + \bar d_2\otimes\bar e_2 + \bar d_3\otimes\bar e_3\), ("Dual Dot Product")

and

\(\vec d \times \vec e ≜ ( \bar d_2\otimes\bar e_3 - \bar d_3\otimes\bar e_2, \bar d_3\otimes\bar e_1 - \bar d_1\otimes\bar e_3, \bar d_1\otimes\bar e_2 - \bar d_2\otimes\bar e_1) \) ("Dual Cross Product")
By Taylor expansion at the real part, remarkably,
\(\begin{align*} f(a+\epsilon b) &= f(a) + \epsilon b f'(a) + \epsilon^2 (...)\\ &= f(a) + \epsilon b f'(a) \end{align*} \)
So a dual passed into a function yields the function and its derivative, encoded in a dual. We saw this above with polynomials as in the binomial expansion above, the derivative rule for powers, \(\frac{d}{dx} d^n = n d^{n-1}\frac{dd}{dx}\) is visible in the second term.

Dual Quaternions

ℍ, after Hamilton, is the set of quaternions. Let \(\sigma \in ℋ\) be a dual quaternion. Interconvertible forms of \(\sigma\) include:

\(\begin{align*} \sigma &≜ p + \epsilon q \ \ | \ \ p,q \in ℍ\\ &= p_0 + \vec p + \epsilon (q_0 + \vec q)\ \ | \ \ \vec p = ip_1 + jp_2 + kp_3, \ \ \vec q = iq_1 +jq_2 + kq_3, \ \ p_i,q_i \in ℝ \\ &= (p_0,p_1,p_2,p_3,q_0,q_1,q_2,q_3)\\ &= p_0 + ip_1 + jp_2 + kp_3 + \epsilon(q_0+iq_1+jq_2+kq_3) \\ &= d + \vec d\ \ |\ \ d=p_0 + \epsilon q_0, \vec d = \vec p + \epsilon \vec q \end{align*} \)
So a Dual Quaternion could be a quaternion made up of dual numbers, or a dual number made up of quaternions; it remains one underlying set of real numbers each scaling one of the eight basis vectors \(1,i,j,k,\epsilon,\epsilon i,\epsilon j,\epsilon k\) of the Dual Quaternion space ℋ.

Dual Quaternion Translation and Rotation

Let \(t = 0+it_1+jt_2+kt_3\) be a translation vector \((t_1,t_2,t_3)\) encoded as a pure quaternion.
Let \(r = cos(\frac{\beta}{2})+sin(\frac{\beta}{2})\hat u\) be a unit quaternion encoding a rotation of angle \(\beta\) around axis \(\hat u\).
Let \(\sigma_{tr} = r+\frac{\epsilon}{2}tr\) be a dual quaternion encoding rotation \(r\) followed by translation \(t\). (Read outside-in.)
Let \(\sigma_{tr}^\diamond = r^*-\frac{\epsilon}{2}(tr)^*\) be the \(\diamond\)-conjugate of \(\sigma_{tr}\).
Let \(V = 1+\epsilon v\) be a dual-number encoding of a source vector \(v\). (So \(V=(1,0,0,0,0,v1,v2,v3)\).)
Then

\( V_{rt} = \sigma_{rt} V \sigma_{rt}^\diamond = 1 + \epsilon v_{rt}\) (Jia proves it)

\(v_{rt}\) emerges from this and is the result of, first, rotating \(v\) by \(r\) and second translating by \(t\).

Reversing the order of operations is simple:
Let \(\sigma_{rt} = r+\frac{\epsilon}{2}(rt)\) be a dual quaternion (this form encodes translation \(t\) followed by rotation \(r\)).
Let \(\sigma_{rt}^\diamond = r^*-\frac{\epsilon}{2}(rt)^*\) be the \(\diamond\)-conjugate of \(\sigma_{rt}\).
Then

\( V_{tr} = \sigma_{tr} V \sigma_{tr}^\diamond = 1 + \epsilon v_{tr}\) (Jia proves it)

\(v_{tr}\) is taken from this, and is the result of, first, translating by \(t\), and second rotating \(v\) by \(r\).

As with quaternions, sequences of dual-quaternion translate-rotate operations can be encoded by nested multiplications.

\( V_{1..n} = \sigma_1 \sigma_2 .. \sigma_n V \sigma_n^\diamond .. \sigma_2^\diamond \sigma_1^\diamond\)
Premultiplication and post-conjugation simplify a sequence of any number of translate-rotates or rotate-translate operations.
Let \( \sigma_{1..n} = \sigma_1 \sigma_2 .. \sigma_n \), then:

\( V_{1..n} = \sigma_{1..n} V (\sigma_{1..n})^\diamond = 1 + \epsilon v_{1..n} \\ \)
Now we have the means to apply sequences of translation-rotation operations to position vectors in local invariant space, not moving them in space, but moving the perspective from which they are seen, in space, by backing away from an event at a location to a view of that event from a different location, with the location of the event represented from that other perspective.

This provides an implementation of the Twist-and-Bend concept whereby spatial information from many sources can be transformed from the perspective of their sensory-data-collection locations, into a common perspective of a central viewing orientation frame, thus merging arbitrary spatially-encoded data into a single spatial view. In a tree-structured body with internal transmission of sensory data, a centrally integrated spatial vision of the whole including body-internal and body-external events, can be constructed using the Twist-and-Bend concept, two methods so far being being this latter one of Dual Quaternion translation and rotation and the other the above method of simple Quaternion translation and rotation. When the branches of a sensory tree each have their spatial view, but each has a relative position and orientation compared with a higher node in the tree, then their information can be combined by rotating to the directional-orientation frame of the parent then translating to the origin of the parent, so that now despite different original sources they can be examined within the same spatial frame.

| NN Top | Introduction | Newton's Method | Fuzzy Logic NNs | & training rule | Twist-and-Bend | Space Representing NNs | Dual Quaternions | Algebroids | Robots |

Your thoughts?
(will not be shared or abused)
Comment:
                                          Feedback is welcome.
Copyright © 2023 Thomas C. Veatch. All rights reserved.
Created: September 30, 2023; Modified October 10, 29, 2023