Sunday, February 23, 2020

New Notation: Some changes to make previous posts on dual quaternions and screw theory consistent.

The previous posts on screw theory and (dual) quaternions are not consistent with each other and need to be made so before they are combined. This post will start on establishing a notation that will be consistent across them all.

First, let's start with the posts on quaternions, Plucker coordinates and dual quaternions. The proposed notation will be as follows.

Regular quaterions will use bold italic lower case lettering. They are composed of a scalar part in lower case italic with a $w$ subscript and a vector part in lower case italic with an arrow above. The vector part can be broken down into it's $i, j, k$ vector components. Subscripts $x, y, z$ on the three scalars will associated them with their $\vec{i},\vec{j},\vec{k}$ vector components as illustrated in the following example:

$$\begin{align} \pmb{p} &= p_w + \vec{p} \\ &= p_w + p_x\vec{i} + p_y\vec{j} + p_z\vec{k} \end{align}$$

The conjugate for the regular quaternion will use a $*$ superscript and the vector components simply use a sign change.

$$\begin{align} \pmb{p^{*}} &= p_w - \vec{p} \\ &= p_w - p_x\vec{i} - p_y\vec{j} - p_z\vec{k} \end{align}$$

Dual quaternions are in bold italic lower case letters with a "hat" symbol above. They are made up of two regular quaternions but one is multiplied by the dual number $\epsilon$. Also, the dual part of the dual quaternion will used an $\epsilon$ subscript on it's regular quaternion scalars as shown below:

$$\begin{align} \pmb{\hat{\sigma}} &= \pmb{\sigma} + \epsilon\pmb{\sigma_{\epsilon}} \\ &= \sigma_w + \sigma_x\vec{i} + \sigma_y\vec{j} + \sigma_z\vec{k} + \epsilon\big(\sigma_{{\epsilon}w} + \sigma_{{\epsilon}x}\vec{i} + \sigma_{{\epsilon}y}\vec{j} + \sigma_{{\epsilon}z}\vec{k}\big) \end{align}$$

There are three types of conjugates associate with dual quaternions and we will use superscripts as shown below to distinguish each type:

  1. The dual number is conjugated

    $$\pmb{\bar{\hat{\sigma}}} = \pmb{\sigma} - \epsilon\pmb{\sigma_{\epsilon}}$$
  2. The quaternion components are conjugated

    $$\pmb{\hat{\sigma}^{*}} = \pmb{\sigma^{*}} + \epsilon\pmb{\sigma_{\epsilon}^{*}}$$
  3. The dual number and quaternion components are both conjugated.

    $$\pmb{\bar{\hat{\sigma}}^{*}} = \pmb{\sigma^{*}} - \epsilon\pmb{\sigma_{\epsilon}^{*}}$$

For the post on screw theory, several images along with the text need new labels. The translation vector $\vec{t}$ needs to be introduced and added to figures. One that requires this addition also uses the capital $\mathsf{T}$ on the screw axis line which could be changed to $\mathsf{S^{'}}$. The scalar $t$ appears later in the article when looking at half-turns and the screw triangle. This can be changed to the letter $h$ instead. Also, $\vec{n}$ is used as the unit direction vector for a screw axis. This will be changed to $\vec{l}$. The letter $l$ appears in the discussion of the half-turn axes and can remain the same since these are scalars in the $\vec{l}$ direction. Figures 15 and 19, change scalars $t$'s to $h$'s. Figures 20, 21, 22 and 23, change $\vec{n}$'s to $\vec{l}$'s. There are also inconsistencies in the use of $\theta$ and $\phi$ between the Mozzi-Chasles paper and the rest that lead to a dual quaternion formulation. It seems easier to use the Mozzi-Chasles convention and change the quaternion and dual quaternion articles to use $\phi$ instead of $\theta$ since much fewer images need changing. Nine images versus two or three images. Text changes are easy since one can just use the replace function on a text editor. The Plucker article can be left with $\theta$'s because these are unrelated or they could be changes to something else like $\alpha$'s.

Wednesday, January 22, 2020

Unit Dual Quaternions, Line Transformations and Plücker Coordinates

BEWARE! THIS DRAFT HAS SOME SYMBOLS THAT DO NOT MATCH THOSE WE HAVE PREVIOUSLY USED. THE LETTER USED FOR TRANSLATION WAS $\vec{d}$ BUT HERE IT IS $\vec{t}$. THE SYMBOL FOR PARALLEL TRANSLATION TO THE AXIS WAS $\vec{d_{\Vert}}$ BUT HERE IT IS $\vec{d}$ AND THEREFORE $d = \Vert\vec{d}\Vert$ SO $\vec{d} = d\vec{l}$.

In Parallelograms, Plücker Coordinates and Dual Numbers we had a line $L$ with Plücker coordinates $\big(\vec{l}, \vec{m} \big)$ where $\vec{l}$ is a unit vector in the direction of line $L$ and $\vec{m} = \vec{p}\times\vec{l}$ where $\vec{p}$ can be chosen perpendicular to $L$ so $\vec{l}\cdot\vec{m} = 0$. Let the dual quaternion of these Plücker coordinates be:

$$\pmb{l} + \epsilon\pmb{m} = \vec{l} + \epsilon\vec{m}\tag{1}$$

The standard dual quaternion $\pmb{r_0} + \frac{\epsilon}{2}\vec{t}\pmb{r_0}$ for translation and rotation is not suited for Plücker Coordinates since it assumes a rotation axis through the origin and that means $\vec{p_{\bot}} = 0$ and $\vec{m} = 0$ which isn't what we want. What we want is this displacement to occur around axis $\mathrm{L}$ which does not pass through the origin but does pass through some point $\mathrm{P}$. We can obtain the dual quaternion for this axis offset by $\vec{p}$ by applying the translation dual quaternion $1 + \epsilon\frac{\vec{p}}{2}$ to the rotation dual quaternion $\pmb{\hat{r}}$ for the unit vector $\vec{l}$. However, from the post Unit Dual Quaternion For Translation And Rotation we can simply change this unit dual quaternion into the regular unit rotation quaternion $\pmb{r_0}$:

$$\pmb{\hat{r}} = \pmb{r_0} + \epsilon(0)$$ Recall that a regular rotation quaternion in terms of $\theta$ was derived in Extracting the Cross and Dot Products from the Quaternion Rotation Operator and for the unit vector $\vec{l}$ would be:

$$\pmb{r_0} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l}$$

Since this will be a transformation operation of the regular quaternion $\pmb{r_0}$, this quaternion has to be multiplied on both sides by the translation quaternion. We have seen this "quaternion sandwich operation" before with rotations but now we are doing it with a translation. The left side is multiplied by $1 + \epsilon\frac{\vec{p}}{2}$ and right is multiplied by the conjugate $1 - \epsilon\frac{\vec{p}}{2}$:

$$\begin{align} \Big(1 + &\epsilon\frac{\vec{p}}{2} \Big)\pmb{r_0}\Big(1 - \epsilon\frac{\vec{p}}{2} \Big) = \Big(1 + \epsilon\frac{\vec{p}}{2} \Big)\Big( \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l}\Big) \Big(1 - \epsilon\frac{\vec{p}}{2} \Big)\\ &= \bigg(\cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \frac{\epsilon}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{p} + \frac{\epsilon}{2}\sin{\Big(\frac{\theta}{2}\Big)}\vec{p}\vec{l}\bigg)\Big(1 - \epsilon\frac{\vec{p}}{2} \Big)\\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \frac{\epsilon}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{p} + \frac{\epsilon}{2}\sin{\Big(\frac{\theta}{2}\Big)}\vec{p}\vec{l} - \frac{\epsilon}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{p} - \frac{\epsilon}{2}\sin{\Big(\frac{\theta}{2}\Big)}\vec{l}\vec{p} \\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{p} \times \vec{l}\Big) \tag{2} \end{align}$$

However, to obtain a general (e.g. screw) displacement dual qauternion, we need to use another translation quaternion, $1 + \epsilon\frac{\vec{d}}{2}$, for the displacement $\vec{d}$ parallel to the rotation axis $L$ to equation $(2)$. Here we are concatenating/combine operations instead of transforming one operation, so there is only a simple one-side multiplication that needs to be done.

$$\begin{align} \bigg(1 + &\epsilon\frac{\vec{d}}{2}\bigg)\bigg( \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{p} \times \vec{l}\Big) \bigg) \\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\bigg(\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{p} \times \vec{l}\Big) + \frac{1}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{d} + \frac{1}{2}\sin{\Big(\frac{\theta}{2}\Big)}\vec{d}\vec{l}\bigg)\tag{3} \end{align}$$ and since $\vec{d}$ is parrallel to $\vec{l}$ then $\vec{d}\vec{l} = \big( \vec{d}\times\vec{l}\big) - \vec{d}\cdot\vec{l} = -d$ and equation $(3)$ becomes

$$\begin{align} & \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\bigg(\sin{\Big(\frac{\theta}{2}\Big)}\vec{m} + \frac{\vec{d}}{2}\cos{\Big(\frac{\theta}{2}\Big)} - \frac{d}{2}\sin{\Big(\frac{\theta}{2}\Big)}\bigg)\\ &= \cos{\Big(\frac{\theta}{2}\Big)} - \epsilon\frac{d}{2}\sin{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\Big(\sin{\Big(\frac{\theta}{2}\Big)}\vec{m} + \frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{l} \Big)\tag{4} \end{align}$$

AN ALTERNATIVE GEOMETRIC DERIVATION OF EQUATION $(4)$

In Figure 1, the screw axis $\mathrm{L}$ has unit direction vector $\vec{l}$ and is represented by Plücker coordinates $(\vec{m}, \vec{l})$ where $\vec{m} = \vec{p}\times\vec{l}$ and $\vec{p}$ is from the origin and can be to any point $\mathrm{P}$ on line $\mathrm{L}$. The following formulas are general for any point $\mathrm{P}$ but we will choose $\vec{p}$ perpendicular to $\mathrm{L}$ so that $\vec{p} = \vec{p}_{\bot}$. Furthermore, $\vec{t}$ is the translation vector of any point by the screw displacement so the distance traveled parallel to $\mathrm{L}$ is $d = \vec{t}\cdot\vec{l}$.


FIGURE 1

To find $\vec{m}$ in terms of the screw displacement, start by screw displacing the origin point of the coordinate system at the tail of $\vec{p}_{\bot}$ as shown in Figure 1. This establishes the geometry we need to work with in finding the equation for the location of point $\mathrm{P}$ at the tip of $\vec{p}_{\bot}$ only in terms of $\vec{t}$, $\vec{l}$, and the rotation angle $\theta$. Next, proceed in a similar manner as the derivation of equations $(2)$ to $(5)$ in post Mozzi-Chasles' Screw Theorem, Half-Turn Equivalence and Combining Successive Screw Displacements.

For $\vec{p_2}+\vec{p_1}$, begin by using the relation

$$ \tan{\Big(\frac{\theta}{2}\Big)} = \frac{\Vert \vec{p_2} - \vec{p_1} \Vert}{\Vert \vec{p_2} + \vec{p_1} \Vert}$$

then cross-multiplying $\vec{p_2}-\vec{p_1}$ with the unit vector $\vec{l}$ to get:

$$ \vec{p_2}+\vec{p_1} = \cot{\Big(\frac{\theta}{2}\Big)} \Big(\vec{p_2}-\vec{p_1}\Big) \times \vec{l}$$

The vector that is half the length of $ \vec{p_2}+\vec{p_1}$ but in the opposite direction from the bisecting point $\mathrm{B}$ to point $\mathrm{P}$ at the tip of $\vec{p}_{\bot}$ is:

$$ -\frac{1}{2}\Big(\vec{p_2}+\vec{p_1}\Big) = \frac{1}{2} \cot{\Big(\frac{\theta}{2}\Big)}\vec{l}\times\Big(\vec{p_2}-\vec{p_1}\Big)$$

and because

$$ \Big(\vec{p_2}-\vec{p_1}\Big) = \vec{t} - \Big(\vec{t}\cdot\vec{l} \Big) \vec{l}$$

then we get

$$ -\frac{1}{2}\Big(\vec{p_2}+\vec{p_1}\Big) = \frac{1}{2} \cot{\Big(\frac{\theta}{2}\Big)}\vec{l}\times\vec{t}$$

From Figure 1 we see that three successive vectors, the first starting from the coordinate system origin to the mid-point of $\vec{t}$, then the second from the mid-point of $\vec{t}$ to point $\mathrm{B}$ and finally the third from point $\mathrm{B}$ towards point $\mathrm{P}$, give the same result as $\vec{p}_{\bot}$. So we have:

$$\begin{align} \vec{p}_{\bot} &= \frac{1}{2}\vec{t} - \frac{1}{2}\Big(\vec{t}\cdot\vec{l} \Big) \vec{l} - \frac{1}{2}\Big(\vec{p_2}+\vec{p_1}\Big) \\ &= \frac{1}{2}\vec{t} - \frac{1}{2}\Big(\vec{t}\cdot\vec{l} \Big) \vec{l} + \frac{1}{2} \cot{\Big(\frac{\theta}{2}\Big)}\vec{l}\times\vec{t}\\ &= \frac{1}{2} \bigg(\vec{t} - \Big(\vec{t}\cdot\vec{l} \Big) \vec{l} + \cot{\Big(\frac{\theta}{2}\Big)}\vec{l}\times\vec{t} \bigg) \end{align}$$

Finally, for $\vec{m}$ we have:

$$\vec{m} = \vec{p}_{\bot} \times \vec{l} = \frac{1}{2} \bigg(\vec{t}\times \vec{l} + \cot{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\times\vec{t}\Big)\times \vec{l} \bigg)\tag{5}$$

We know from post Unit Dual Quaternion For Translation And Rotation that we use the dual qauternion rotation and translation operator:

$$\pmb{r_0} + \frac{\epsilon}{2}\vec{t}\pmb{r_0}\tag{6}$$

We recall from equation $(23)$ of the post Extracting the Cross and Dot Products from the Quaternion Rotation Operator that:

$$ \pmb{r_0} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l}\tag{7}$$

Substituting equation $(7)$ into $(6)$ gives:

$$\begin{align} \pmb{r_0} + \frac{\epsilon}{2}\vec{t}\pmb{r_0} &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)}\vec{t} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{t}\vec{l}\bigg)\\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)}\vec{t} - \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{t}\cdot\vec{l}\Big) + \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{t}\times\vec{l}\Big)\bigg)\tag{8}\\ \end{align}$$

Now let's multiply both sides of equation $(5)$ by $\sin{\big(\frac{\theta}{2} \big)}$:

$$\sin{\Big(\frac{\theta}{2} \Big)}\vec{m} = \frac{1}{2} \bigg(\sin{\Big(\frac{\theta}{2} \Big)}\Big(\vec{t}\times \vec{l}\Big) + \cos{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\times\vec{t}\Big)\times \vec{l} \bigg)\tag{9}$$

rearranging $(9)$:

$$\sin{\Big(\frac{\theta}{2} \Big)}\Big(\vec{t}\times \vec{l}\Big) = 2\sin{\Big(\frac{\theta}{2} \Big)}\vec{m} - \cos{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\times\vec{t}\Big)\times \vec{l}\tag{10}$$

Substituting $(10)$ into $(8)$ gives:

$$\begin{align} \pmb{r_0} + \frac{\epsilon}{2}&\vec{t}\pmb{r_0}\\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l}\\ &+ \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)}\vec{t} - \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{t}\cdot\vec{l}\Big) + 2\sin{\Big(\frac{\theta}{2} \Big)}\vec{m} - \cos{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\times\vec{t}\Big)\times \vec{l}\bigg)\\\\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l}\\ &+ \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)}\vec{t} - \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{t}\cdot\vec{l}\Big) + 2\sin{\Big(\frac{\theta}{2} \Big)}\vec{m} + \cos{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\cdot\vec{t}\Big)\vec{l} - \cos{\Big(\frac{\theta}{2}\Big)}\vec{t}\bigg)\\\\ &= \cos{\Big(\frac{\theta}{2}\Big)} - \frac{\epsilon}{2}\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{t}\cdot\vec{l}\Big)\\ &+ \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\bigg( \sin{\Big(\frac{\theta}{2} \Big)}\vec{m} + \frac{1}{2}\cos{\Big(\frac{\theta}{2}\Big)}\Big(\vec{l}\cdot\vec{t}\Big)\vec{l}\bigg)\\ \\ &= \cos{\Big(\frac{\theta}{2}\Big)} - \epsilon\frac{d}{2}\sin{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\bigg(\sin{\Big(\frac{\theta}{2}\Big)}\vec{m} + \frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)}\vec{l} \bigg)\tag{11} \end{align}$$

Equations $(4)$ and $(11)$ are the same and can be simplified further since a Taylor series expansion of every function $f$ of dual numbers yeilds the rule that:

$$ f\big(a + \epsilon b \big) = f\big(a\big) + \epsilon b f^{'}\big(a\big)$$

hence

$$\begin{align} \cos{\Big(\frac{\theta + \epsilon d}{2}\Big)} &= \cos{\Big(\frac{\theta}{2}\Big)} - \epsilon\frac{d}{2}\sin{\Big(\frac{\theta}{2}\Big)}\\ \sin{\Big(\frac{\theta + \epsilon d}{2}\Big)} &= \sin{\Big(\frac{\theta}{2}\Big)} + \epsilon\frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)} \end{align}$$

Letting $\sigma = \pmb{r_0} + \frac{\epsilon}{2}\vec{t}\pmb{r_0}$ and substituting the two equations above into $(4)$ or $(11)$ gives us:

$$\begin{align} \sigma &= \pmb{r_0} + \frac{\epsilon}{2}\vec{t}\pmb{r_0}\\ &=\cos{\Big(\frac{\theta + \epsilon d}{2}\Big)} + \bigg(\sin{\Big(\frac{\theta}{2}\Big)} + \epsilon\frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)}\bigg)\vec{l} + \sin{\Big(\frac{\theta}{2}\Big)}\epsilon\vec{m}\\ &=\cos{\Big(\frac{\theta + \epsilon d}{2}\Big)} + \bigg(\sin{\Big(\frac{\theta}{2}\Big)} + \epsilon\frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)}\bigg)\vec{l} + \bigg(\sin{\Big(\frac{\theta}{2}\Big)} + \epsilon\frac{d}{2}\cos{\Big(\frac{\theta}{2}\Big)}\bigg)\epsilon\vec{m}\\ &= \cos{\Big(\frac{\theta + \epsilon d}{2}\Big)} + \sin{\Big(\frac{\theta + \epsilon d}{2}\Big)}\Big(\vec{l} + \epsilon\vec{m} \Big)\tag{12} \end{align}$$

By introducing the following dual angle and dual vector

$$\begin{align} \bar{\theta} &= \theta + \epsilon d \\ \bar{\vec{l}} &= \vec{l} + \epsilon\vec{m} \end{align}$$

then equation $(12)$ can be rewritten into a very succinct form:

$$\sigma = \cos{\Big(\frac{\bar{\theta}}{2}\Big)} + \bar{\vec{l}}\sin{\Big(\frac{\bar{\theta}}{2}\Big)}\tag{13} $$







IGNORE BELOW.

Applying the dual quaternion displacement operator to the Plücker Coordinates

$$\begin{align} \pmb{\hat{s}}\big(\vec{l} + \epsilon\vec{m}\big)\pmb{\bar{\hat{s}}^{*}} &= \big(\pmb{r_0} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\big)\big( \vec{l} + \epsilon\vec{m}\big)\big( \pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{{r_0}^{*}}\vec{d}^{*}\big) \\ &= \big(\pmb{r_0}\vec{l} + \epsilon\pmb{r_0}\vec{m} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\vec{l}\big)\big( \pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{{r_0}^{*}}\vec{d}^{*}\big)\\ &= \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\vec{d}^{*} + \epsilon\pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\\ &= \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} + \epsilon\bigg(\pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \frac{1}{2}\Big(\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\vec{d}^{*} + \vec{d}\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\Big) \bigg)\tag{2} \\ \end{align}$$

Letting $\vec{l^{'}} + \epsilon\vec{m^{'}} = \pmb{\hat{s}}\big(\vec{l} + \epsilon\vec{m}\big)\pmb{\bar{\hat{s}}^{*}}$ then:

$$\begin{align} \vec{l^{'}} &= \pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\tag{3} \\ \vec{m^{'}} &= \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \frac{1}{2}\Big( \pmb{r_0} \vec{l} \pmb{{r_0}^{*}} \vec{d}^{*} + \vec{d}\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\Big) \\ &= \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \frac{1}{2}\bigg( \Big(\pmb{r_0} \vec{l} \pmb{{r_0}^{*}}\Big) \cdot \vec{d} - \Big(\pmb{r_0} \vec{l} \pmb{{r_0}^{*}} \times \vec{d}\Big) - \vec{d} \cdot \Big(\pmb{r_0} \vec{l} \pmb{{r_0}^{*}}\Big) + \Big(\vec{d} \times \pmb{r_0} \vec{l} \pmb{{r_0}^{*}} \Big)\bigg) \\ &= \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \vec{d} \times \pmb{r_0} \vec{l} \pmb{{r_0}^{*}}\tag{4} \\ \end{align}$$

Therfore

$$\vec{l^{'}} + \epsilon\vec{m^{'}} = \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} + \epsilon\Big( \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \vec{d} \times \pmb{r_0} \vec{l} \pmb{{r_0}^{*}} \Big)\tag{5}$$

In terms of $\theta$ we use equation $(23)$ from Extracting the Cross and Dot Products from the Quaternion Rotation Operator and have

$$\begin{align} \vec{l^{'}} &= \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} \\ \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{m} \end{align}$$ which are substituted into $(4)$ above to give:

$$\begin{align} \vec{m^{'}} &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{m} + \cos{\Big(\frac{\theta}{2}\Big)}\vec{d} + \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{d}\times\vec{l}\Big)\tag{6} \\ \end{align}$$

Therefore:

$$\vec{l^{'}} + \epsilon\vec{m^{'}} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{l} + \epsilon\bigg(\cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{m} + \cos{\Big(\frac{\theta}{2}\Big)}\vec{d} + \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{d}\times\vec{l}\Big)\bigg)\tag{7}$$

Since $\vec{m} = \vec{p}\times\vec{l}$ in equation $(6)$, let's first look at what happens to $\vec{p}$ with transformation. From equation $(7)$ in Unit Dual Quaternion For Translation And Rotation, we have for $1 + \epsilon\vec{p}$:

$$1 + \epsilon\vec{p^{'}} = 1 + \epsilon\big(\pmb{r_0}\vec{p}\pmb{{r_0}^{*}} + \vec{d}\big)$$

and therefore:

$$\vec{p^{'}} = \pmb{r_0}\vec{p}\pmb{{r_0}^{*}} + \vec{d}$$

Now since vectors $\vec{l}$ and $\vec{p}$ are rotated around the same axis by the same amount then their cross-product $\vec{m}$ is as well so $\pmb{r_0}\vec{m}\pmb{{r_0}^{*}} = \pmb{r_0}\big(\vec{p}\times\vec{l}\big)\pmb{{r_0}^{*}} = \pmb{r_0}\vec{p}\pmb{{r_0}^{*}} \times \pmb{r_0}\vec{l}\pmb{{r_0}^{*}}$ and:

$$\begin{align} \vec{m^{'}} &= \vec{p^{'}}\times\vec{l^{'}} \\ &= \Big( \pmb{r_0}\vec{p}\pmb{{r_0}^{*}} + \vec{d} \Big) \times \Big( \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} \Big) \\ &= \pmb{r_0}\vec{p}\pmb{{r_0}^{*}} \times \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} + \vec{d} \times \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} \\ &= \pmb{r_0}\vec{m}\pmb{{r_0}^{*}} + \vec{d} \times \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} \end{align}$$

Since the cross-product of two pure quaternions $\vec{a}$ and $\vec{b}$ is $\vec{a}\times\vec{b} = \frac{1}{2}\Big(\vec{b}\vec{a}^{*} + \vec{a}\vec{b} \Big)$ then:

$$ \vec{d} \times \pmb{r_0}\vec{l}\pmb{{r_0}^{*}} = \frac{1}{2}\Big(\pmb{r_0}\vec{l}\pmb{{r_0}^{*}}\vec{d}^{*} + \vec{d}^{*}\pmb{r_0}\vec{l}\pmb{{r_0}^{*}} \Big)$$

Wednesday, January 8, 2020

Extracting the Cross and Dot Products from the Quaternion Rotation Operator

The product of two regular quaternions $\pmb{r} = r_0 + \vec{r}$ and $\pmb{v} = 0 + \vec{v}$ is:

$$\begin{align} \pmb{r}\vec{v} &= \big( r_0 + \vec{r}\big)\big(\vec{v} \big) \\ &= \big( r_0 + r_x\vec{i}+ r_y\vec{j} + r_z\vec{k}\big)\big(v_x\vec{i}+ v_y\vec{j} + v_z\vec{k} \big) \\ \\ &= r_{0}v_{x}\vec{i} + r_{0}v_{y}\vec{j} + r_{0}v_{z}\vec{k} \\ &\quad - r_{x}v_{x} + r_{x}v_{y}\vec{k} - r_{x}v_{z}\vec{j} \\ &\quad - r_{y}v_{x}\vec{k} - r_{y}v_{y} + r_{y}v_{z}\vec{i} \\ &\quad + r_{z}v_{x}\vec{j} - r_{z}v_{y}\vec{i} - r_{z}v_{z} \tag{1} \end{align}$$

Rearranging the terms in equation $\big(1\big)$ as follows:

$$\begin{align} \pmb{r}\vec{v} &= -\big(r_{x}v_{x} + r_{y}v_{y} + r_{z}v_{z}\big) \\ &\quad+ r_{0}\big(v_{x}\vec{i} + v_{y}\vec{j} + v_{z}\vec{k}\big) \\ &\quad+ \big(r_{y}v_{z} - r_{z}v_{y}\big)\vec{i} + \big(r_{z}v_{x} - r_{x}v_{z} \big)\vec{j} + \big( r_{x}v_{y} - r_{y}v_{x}\big)\vec{k}\tag{2} \\ \\ &= - \vec{r}\cdot\vec{v} + r_{0}\vec{v} + \vec{r} \times \vec{v} \tag{3} \end{align}$$

Right multiplying equation $\big(3\big)$ by the conjugate $\pmb{r}^{*} = r_{0} - \vec{r}$ gives:

$$\begin{align} \pmb{r}\vec{v}\pmb{r}^{*} &= \big(- \vec{r}\cdot\vec{v} + r_{0}\vec{v} + \vec{r} \times \vec{v}\big)\big(r_{0} - \vec{r} \big) \\ &= -(\vec{r}\cdot\vec{v})r_{0} + (\vec{r}\cdot\vec{v})\vec{r} + \big(\vec{v}r_{0} + (\vec{r} \times \vec{v})\big)r_{0} + \big(\vec{v}r_{0} + (\vec{r} \times \vec{v})\big)(-\vec{r}) \\ &= -(\vec{r}\cdot\vec{v})r_{0} + (\vec{r}\cdot\vec{v})\vec{r} + \vec{v}r_{0}^2 + (\vec{r} \times \vec{v})r_{0} +\vec{v}r_{0}(-\vec{r} ) + (\vec{r} \times \vec{v})(-\vec{r})\tag{4} \\ \end{align}$$

Expanding and rearranging the term $(\vec{r} \times \vec{v})(-\vec{r})$ and letting $\vec{m} = \vec{r} \times \vec{v}$:

$$\begin{align} (\vec{r} \times \vec{v})(-\vec{r})&= \big(r_{y}v_{z} - r_{z}v_{y}\big)\vec{i}\big( r_0 - r_x\vec{i}- r_y\vec{j} - r_z\vec{k} \big) \\ &\quad+ \big(r_{z}v_{x} - r_{x}v_{z} \big)\vec{j}\big( r_0 - r_x\vec{i}- r_y\vec{j} - r_z\vec{k} \big) \\ &\quad+ \big( r_{x}v_{y} - r_{y}v_{x}\big)\vec{k}\big(r_0 - r_x\vec{i}- r_y\vec{j} - r_z\vec{k} \big)\tag{5} \\ \\ &= m_{x}r_0\vec{i} + m_{x}r_x - m_{x}r_y\vec{k} + m_{x}r_z\vec{j} \\ &\quad+ m_{y}r_0\vec{j} + m_{y}r_x\vec{k} + m_{y}r_y - m_{y}r_z\vec{i} \\ &\quad+ m_{z}r_0\vec{k} - m_{z}r_x\vec{j} + m_{z}r_y\vec{i} + m_{z}r_z\tag{6} \\ \\ &= m_{x}r_x + m_{y}r_y + m_{z}r_z \\ &\quad+ r_0\big(m_{x}\vec{i} + m_{y}\vec{j} + m_{z}\vec{k}\big) \\ &\quad+ \big(m_{z}r_y - m_{y}r_z\big)\vec{i} + \big(m_{x}r_z - m_{z}r_x \big)\vec{j} + \big(m_{y}r_x - m_{x}r_y \big)\vec{k}\tag{7} \\ \\ &= \big(\vec{r} \times \vec{v}\big) \cdot \vec{r} + r_{0}\big(\vec{r} \times \vec{v}\big) - \big(\vec{r} \times \vec{v}\big)\times\vec{r}\tag{8} \end{align}$$

The following term has this vector triple product expansion:

$$\begin{align} \big(\vec{r} \times \vec{v}\big)\times\vec{r} &= -\big(\vec{r}\cdot\vec{v}\big)\vec{r} + \big(\vec{r}\cdot\vec{r}\big)\vec{v} \\ &= -\big(\vec{r}\cdot\vec{v}\big)\vec{r} + \Vert\vec{r}\Vert^2\vec{v} \end{align}$$

Since $\big(\vec{r} \times \vec{v}\big) \cdot \vec{r} = 0$ then $(8)$ becomes:

$$(\vec{r} \times \vec{v})(-\vec{r} )= r_{0}\big(\vec{r} \times \vec{v}\big)+\big(\vec{r}\cdot\vec{v}\big)\vec{r} - \Vert\vec{r}\Vert^2\vec{v}\tag{9}$$

Expanding and rearranging $\vec{v}(-\vec{r})$ in the term $\vec{v}r_{0}(-\vec{r})$:

$$\begin{align} \vec{v}(-\vec{r}) &= \big(v_{x}\vec{i} + v_{y}\vec{j} + v_{z}\vec{k}\big)\big(-r_{x}\vec{i} - r_{y}\vec{j} - r_{z}\vec{z} \big) \\ &= v_{x}r_{x} - v_{x}r_{y}\vec{k} + v_{x}r_{z}\vec{j} \\ &\quad v_{y}r_{x}\vec{k} + v_{y}r_{y} - v_{y}r_{z}\vec{i} \\ &\quad -v_{z}r_{x}\vec{j} + v_{z}r_{y}\vec{i} + v_{z}r_{z} \\ \\ &= \big(v_{x}r_{x} + v_{y}r_{y} + v_{z}r_{z}\big) \\ &\quad +\big(-v_{y}r_{z} + v_{z}r_{y}\big)\vec{i} + \big(-v_{z}r_{x} + v_{x}r_{z}\big)\vec{j}+\big(-v_{x}r_{y} + v_{y}r_{x}\big)\vec{k} \\ \\ &= \vec{v}\cdot \vec{r} - \vec{v} \times \vec{r} \\ &= \vec{r}\cdot \vec{v} + \vec{r} \times \vec{v}\tag{10} \end{align}$$

The terms $\vec{v}r_{0}(-\vec{r}) +(\vec{r} \times \vec{v})(-\vec{r})$ in $(4)$ then become:

$$\begin{align} \vec{v}r_{0}(-\vec{r}) +(\vec{r} \times \vec{v})(-\vec{r}) &= r_{0}(\vec{r}\cdot \vec{v}) + r_{0}(\vec{r} \times \vec{v}) +r_{0}\big(\vec{r} \times \vec{v}\big)+\big(\vec{r}\cdot\vec{v}\big)\vec{r} - \Vert\vec{r}\Vert^2\vec{v} \\ &= r_{0}(\vec{r}\cdot \vec{v}) + 2r_{0}(\vec{r} \times \vec{v})+\big(\vec{r}\cdot\vec{v}\big)\vec{r} - \Vert\vec{r}\Vert^2\vec{v}\tag{11} \end{align}$$

Substituting $\big(11\big)$ into equation $\big(4\big)$:

$$-(\vec{r}\cdot\vec{v})r_{0} + (\vec{r}\cdot\vec{v})\vec{r} + \vec{v}r_{0}^2 + (\vec{r} \times \vec{v})r_{0} +r_{0}(\vec{r}\cdot \vec{v}) + 2r_{0}(\vec{r} \times \vec{v})+\big(\vec{r}\cdot\vec{v}\big)\vec{r} - \Vert\vec{r}\Vert^2\vec{v}\tag{12}$$

Reducing $\big(12\big)$ gives the pure quaternion:

$$\pmb{r}\vec{v}\pmb{r}^{*} = \big(r_{0}^2-\Vert\vec{r}\Vert^2\big)\vec{v} +2\big(\vec{r}\cdot\vec{v}\big)\vec{r} + 2r_{0}\big(\vec{r}\times\vec{v}\big)\tag{13}$$

Next we need to find out what rotation the unit quaternion $\pmb{r}$ represents. Substituting $\vec{r}$ for $\vec{v}$ in $\big(13\big)$ makes $\vec{v} = \vec{r}$ collinear with the axis of rotation and yields:

$$\begin{align} \pmb{r}\vec{v}\pmb{r}^{*} &= \big(r_{0}^2-\Vert\vec{r}\Vert^2\big)\vec{v} +2\big(\vec{r}\cdot\vec{v}\big)\vec{r} + 2r_{0}\big(\vec{r}\times\vec{v}\big)\\ &= \big(r_{0}^2+\Vert\vec{r}\Vert^2\big)\vec{r}\\ &= \vec{r}\tag{14} \end{align}$$

As it should, $\pmb{r}\vec{v}\pmb{r}^{*}$ remains the same as $\vec{r}$ after the rotation.

Finally, we need to determine the angle of rotation $\theta$. Let the vector $\vec{v}$ be perpendicular to the axis of rotation and then turned into a vector $\vec{{v}^{'}}$ making an angle $\theta$ with $\vec{v}$. In Figure 1 the position vector $\vec{a}$ is associated with $\vec{v}$ and then choosing $\vec{v} = \vec{r} \times \vec{a}$ where $\vec{a}$ is not parallel to $\vec{r}$ gives:

$$\vec{{v}^{'}} = \big(r_{0}^2-\Vert\vec{r}\Vert^2\big)\big(\vec{r} \times \vec{a}\big) +2\big(\vec{r}\cdot\big(\vec{r} \times \vec{a}\big)\big)\vec{r} + 2r_{0}\big(\vec{r}\times\big(\vec{r} \times \vec{a}\big)\big)\tag{15}$$

Figure 1

We find that

$$\begin{align} \vec{v}\cdot\vec{{v}^{'}} &=\big(\vec{r} \times \vec{a}\big)\cdot\Big( \big(r_{0}^2-\Vert\vec{r}\Vert^2\big)\big(\vec{r} \times \vec{a}\big) +2\big(\vec{r}\cdot\big(\vec{r} \times \vec{a}\big)\big)\vec{r} + 2r_{0}\big(\vec{r}\times\big(\vec{r} \times \vec{a}\big)\big) \Big) \\ &= \big(r_{0}^{2} - \Vert\vec{r}\Vert^{2} \big)\Vert \vec{r} \times \vec{a} \Vert^{2}\\ &= \big(r_{0}^{2} - \Vert\vec{r}\Vert^{2} \big)\Vert v \Vert^{2}\tag{16} \end{align}$$

Since $\Vert \vec{{v}^{'}} \Vert = \Vert \vec{v} \Vert$ and $\vec{v}\cdot\vec{{v}^{'}} = \Vert \vec{{v}^{'}} \Vert \Vert \vec{v} \Vert\cos{(\theta)}$ then

$$r_{0}^{2} - \Vert\vec{r}\Vert^{2} = \cos{(\theta)}\tag{17}$$

Noting that $\pmb{r}$ is a unit quaternion then $r_{0}^{2} + \Vert\vec{r}\Vert^{2} = 1$ and this is added to $\big(17\big)$:

$$\begin{align} r_{0}^{2} + \Vert\vec{r}\Vert^{2} + r_{0}^{2} - \Vert\vec{r}\Vert^{2} &= 1 + \cos{(\theta)}\\ 2r_{0}^{2} &= 1 + \cos{(\theta)}\tag{18} \end{align}$$

Using the trigonometric half-angle formula $\cos^2{\Big(\frac{\theta}{2}\Big)} = \frac{1 + \cos{(\theta)}}{2}$ on $\big(18\big)$ gives:

$$r_{0} = \pm\cos{\Big(\frac{\theta}{2}\Big)}\tag{19}$$

Now if $\big(17\big)$ is subtracted from $r_{0}^{2} + \Vert\vec{r}\Vert^{2} = 1$ then:

$$\begin{align} r_{0}^{2} + \Vert\vec{r}\Vert^{2} - r_{0}^{2} + \Vert\vec{r}\Vert^{2} &= 1 - \cos{(\theta)}\\ 2\Vert\vec{r}\Vert^{2} &= 1 - \cos{(\theta)}\tag{20} \end{align}$$

Using the trigonometric half-angle formula $\sin^2{\Big(\frac{\theta}{2}\Big)} = \frac{1 - \cos{(\theta)}}{2}$ on $\big(20\big)$ gives:

$$\Vert\vec{r}\Vert= \sin{\Big(\frac{\theta}{2}\Big)}\tag{21}$$

Let $\vec{u}$ be the unit direction vector of the axis of rotation and $\vec{r}$:

$$\vec{r} = \pm\sin{\Big(\frac{\theta}{2}\Big)}\vec{u}\tag{22}$$

Finally

$$\pmb{r} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{u}\tag{23}$$

Using equations $(13)$, $(19)$ and $(22)$ with the trigonometric identities:

$$\begin{align} \cos^{2}{\Big(\frac{\theta}{2}\Big)} - \sin^{2}{\Big(\frac{\theta}{2}\Big)} &= \cos{\big(\theta\big)}\\ 2\sin{\Big(\frac{\theta}{2}\Big)}\cos{\Big(\frac{\theta}{2}\Big)} &= \sin{\big(\theta\big)}\\ \sin^2{\Big(\frac{\theta}{2}\Big)} &= \frac{1 - \cos{(\theta)}}{2} \end{align}$$

we obtain the Rodrigues' rotation formula:

$$\begin{align} \vec{{v}^{'}} &=\bigg( \cos^2{\Big(\frac{\theta}{2}\Big)} - \sin^{2}{\Big(\frac{\theta}{2}\Big)} \bigg)\vec{v} + 2\cos{\Big(\frac{\theta}{2}\Big)}\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{u} \times \vec{v} \Big)+ 2\sin^2{\Big(\frac{\theta}{2}\Big)}\Big( \vec{u}\cdot \vec{v}\Big)\vec{u}\\ &= \cos{(\theta)}\vec{v} + \sin{(\theta)}\big(\vec{u} \times \vec{v}\big) + \big(1 - \cos{(\theta)}\big)\big(\vec{u} \cdot \vec{v}\big)\vec{u}\tag{24} \end{align}$$

Tuesday, December 31, 2019

Parallelograms, Plucker Coordinates and Dual Numbers

Figure $\mathrm{1}$ will be used to point out some properties of parallelograms that have bearing on Plucker coordinates. The two parallelograms $\mathrm{1}$ and $\mathrm{2}$ shown in the figure have the same base lengths $\mathrm{b}$ and the same length heights $\mathrm{h}$.


Figure 1

The area $\mathrm{A}$ of a parallelogram is just:

$$\mathrm{A} = \mathrm{b}\mathrm{h}\tag{1}$$

So both parallelograms have the same area:

$$\mathrm{A_1} = \big(\mathrm{a} + \mathrm{b}\big)\mathrm{h} - \frac{1}{2}\big(\mathrm{a}\mathrm{h} + \mathrm{a}\mathrm{h}\big) = \mathrm{b}\mathrm{h}$$ $$\mathrm{A_2} = \big(\mathrm{c} + \mathrm{b}\big)\mathrm{h} - \frac{1}{2}\big(\mathrm{c}\mathrm{h} + \mathrm{c}\mathrm{h}\big) = \mathrm{b}\mathrm{h}$$

Therefore

$$\mathrm{A_1} = \mathrm{A_2} $$

This will be the case for all parallelograms of same length bases and heights independent of the lengths like $\mathrm{a}$ and $\mathrm{c}$ and therefore independent of the length of their diagonals like $\mathrm{d_1}$ and $\mathrm{d_2}$.

Since the acute angle between a diagonal $\mathrm{d}$ and it's base $\mathrm{b}$ is $\theta$ then the area of a parallelogram can be written as:

$$\mathrm{A} = \mathrm{b}\mathrm{d}\sin{(\theta)}\tag{2}$$

If we associate the vector $\vec{b}$ with the base $\mathrm{b}$ and vector $\vec{d}$ with the diagonal $\mathrm{d}$ then the area of the parallelogram is the same as the absolute value of $\vec{b} \times \vec{d}$:

$$\Vert \vec{b} \times \vec{d} \Vert = \Vert \vec{b} \Vert\Vert \vec{d} \Vert \sin{(\theta)} = \mathrm{A}\tag{3}$$

Which also means from our two parallelograms that:

$$\begin{align} \Vert \vec{b} \Vert\Vert \vec{d_1} \Vert \sin{(\theta_1)} &= \Vert \vec{b} \Vert\Vert \vec{d_2} \Vert \sin{(\theta_2)} \\ \Vert \vec{b} \times \vec{d_1} \Vert &= \Vert \vec{b} \times \vec{d_2} \Vert \end{align}$$

Let the direction of the cross products be given by the unit vector $\vec{u_m}$ then:

$$\vec{b} \times \vec{d} = \Vert \vec{b} \Vert\Vert \vec{d} \Vert \sin{(\theta)} \vec{u_m}$$

If both cross products have the same direction $\vec{u_m}$ we then have:

$$ \vec{b} \times \vec{d_1} = \vec{b} \times \vec{d_2}$$

Figure $\mathrm{2}$ shows a line $\mathrm{L}$ in $\mathrm{3D}$ space with vectors $\vec{p}$ and $\vec{p_{\perp}}$ to points on $\mathrm{L}$, a vector $\vec{l}$ parallel with line $\mathrm{L}$ and the vector $\vec{m} = \vec{p} \times \vec{l}$.


Figure 2

The vector $\vec{p_{\perp}}$ happens to be perpendicular to $\mathrm{L}$ but from our previous discussion, a vector $\vec{q}$ to any point on $\mathrm{L}$ will satisfy the following equality:

$$ \vec{q} \times \vec{l} = \vec{p} \times \vec{l} = \vec{m} $$

Now if you have $\vec{l}$ and $\vec{m}$ then how do you find $\vec{q}$ given that $\vec{q}$ can be to any point on the line $\mathrm{L}$? We can make this well-defined by choosing $\vec{q} = \vec{p_{\perp}}$. With this choice, $\vec{l}$, $\vec{p_{\perp}}$ and $\vec{m}$ are orthogonal thus $\vec{l} \cdot \vec{p_{\perp}} = 0$ and vector $\vec{l} \times \vec{m}$ is in the same direction as $\vec{p_{\perp}}$ with magnitude

$$\begin{align} \Vert \vec{l} \times \vec{m} \Vert &= \Vert \vec{l} \Vert\Vert \vec{m} \Vert \\ &= \Vert \vec{l} \Vert\Vert \vec{p_{\perp}} \times \vec{l} \Vert \\ &= {\Vert \vec{l} \Vert}^{2}\Vert \vec{p_{\perp}}\Vert \end{align}$$

and therefore

$$\Vert \vec{p_{\perp}} \Vert = \frac{\Vert \vec{l} \times \vec{m} \Vert}{{\Vert \vec{l} \Vert}^{2}} = \frac{\Vert \vec{m} \Vert}{\Vert \vec{l} \Vert}\tag{4}$$ $$\vec{p_{\perp}} = \frac{\vec{l} \times \vec{m}}{{\Vert \vec{l} \Vert}^{2}}\tag{5}$$

By making $\vec{l}$ a unit vector, $\Vert \vec{l} \Vert = 1$, we get:

$$\Vert \vec{p_{\perp}} \Vert = \Vert \vec{m} \Vert\tag{6}$$ $$\vec{p_{\perp}} = \vec{l} \times \vec{m}\tag{7}$$

Another way to get equation $(7)$ is with a vector triple product expansion of $\vec{l} \times \vec{m} = \vec{l} \times \big(\vec{p_{\perp}} \times \vec{l}\big)$.

$$\begin{align} \vec{l} \times \big(\vec{p_{\perp}} \times \vec{l}\big) &= \big(\vec{l} \cdot \vec{l} \big)\vec{p_{\perp}} - \big(\vec{l} \cdot \vec{p_{\perp}} \big) \vec{l} \\ &= {\Vert \vec{l} \Vert}^{2} \vec{p_{\perp}} \\ {\Vert \vec{l} \Vert}^{2} \vec{p_{\perp}} &= \vec{l} \times \vec{m} \\ \vec{p_{\perp}} &= \frac{\vec{l} \times \vec{m}}{{\Vert \vec{l} \Vert}^{2}} = \vec{l} \times \vec{m} \tag{8} \end{align}$$

Unit vector $\vec{l}$ and vector $\vec{m}$ will be the Plucker coordinates $\big(\vec{l}, \vec{m}\big)$ of line $\mathrm{L}$. The dual number representation $\pmb{\hat{l}}$ of these coordinates is:

$$\begin{align} \pmb{\hat{l}} &= \pmb{l} + \epsilon \pmb{m} \\ &= \big(0 + \vec{l}\big) + \epsilon \big(0 + \vec{m}\big) \\ &= \vec{l} + \epsilon \vec{m} \end{align}$$

where $\vec{l} = \mathrm{x_l}\vec{i} + \mathrm{y_l}\vec{j} + \mathrm{z_l}\vec{k}$ and $\vec{m} = \mathrm{x_m}\vec{i} + \mathrm{y_m}\vec{j} + \mathrm{z_m}\vec{k}$.

Wednesday, December 25, 2019

Unit Dual Quaternion For Translation And Rotation

Like in regular unit quaternion product or "sandwich" for a rotation, we will use the unit dual quaternion $\pmb{\hat{q}}$ and one of it's conjugates $\pmb{\bar{\hat{q}}^{*}}$ on a dual quaternion of a vector $\vec{v} = a\vec{i} + b\vec{j} + c\vec{k}$ to first perform product ("sandwich") for a translation of $\vec{v}$.

$$\begin{align} \big(\pmb{q_0} + \epsilon\pmb{q_{\epsilon}}\big)&\big( 1 + \epsilon\vec{v}\big)\big( \pmb{q_{0}^{*}} - \epsilon\pmb{q_{\epsilon}^{*}} \big) \\ &= \big(\pmb{q_0} + \epsilon\pmb{q_{\epsilon}}\big)\big( \pmb{q_{0}^{*}} - \epsilon\pmb{q_{\epsilon}^{*}} \big) + \big(\pmb{q_0} + \epsilon\pmb{q_{\epsilon}}\big)\epsilon\vec{v}\big( \pmb{q_{0}^{*}} - \epsilon\pmb{q_{\epsilon}^{*}} \big) \\ &= \pmb{q_0}\pmb{q_{0}^{*}} - \epsilon\big(\pmb{q_0}\pmb{q_{\epsilon}^{*}} - \pmb{q_{0}^{*}}\pmb{q_{\epsilon}}\big) - {\epsilon}^2\pmb{q_{\epsilon}}\pmb{q_{\epsilon}^{*}} + \epsilon\pmb{q_0}\vec{v}\pmb{q_{0}^{*}} - {\epsilon}^2\big(\pmb{q_0}\vec{v}\pmb{q_{\epsilon}^{*}} - \pmb{q_{\epsilon}}\vec{v}\pmb{q_{0}^{*}}\big) - {\epsilon}^3\pmb{q_{\epsilon}}\vec{v}\pmb{q_{\epsilon}^{*}} \\ &= 1 - \epsilon\big(\pmb{q_0}\pmb{q_{\epsilon}^{*}} - \pmb{q_{0}^{*}}\pmb{q_{\epsilon}}\big) + \epsilon\pmb{q_0}\vec{v}\pmb{q_{0}^{*}}\tag{1} \end{align}$$

Expanding the following terms from equation $\big(1\big)$:

$$\begin{align} \pmb{q_0}\pmb{q_{\epsilon}^{*}} - \pmb{q_{0}^{*}}\pmb{q_{\epsilon}} &= \big(w_0 + \vec{q}_{0}\big)\big( w_{\epsilon} - \vec{q}_{\epsilon}\big) - \big(w_0 - \vec{q}_{0}\big)\big( w_{\epsilon} + \vec{q}_{\epsilon}\big) \\ &= -2w_0\vec{q}_{\epsilon} + 2\vec{q}_{0}w_{\epsilon} \end{align}$$

Since $\pmb{\hat{q}}$ is a unit dual quaternion, we can choose $w_0 = 1$, $\vec{q}_{0} = 0$ and $w_{\epsilon} = 0$ then

$$w_0^2 + x_0^2 + y_0^2 + z_0^2 = (1)^2 + (0)^2 + (0)^2 + (0)^2 = 1$$ $$w_0 w_{\epsilon} + x_0 x_{\epsilon} + y_0 y_{\epsilon} + z_0 z_{\epsilon} = (1)(0) + (0)x_{\epsilon} + (0)y_{\epsilon} + (0)z_{\epsilon} = 0$$

These values satisfy the unit condition and we get:

$$-2w_0\vec{q}_{\epsilon} + 2\vec{q}_{0}w_{\epsilon} = -2\vec{q}_{\epsilon}$$

Likewise for the remaining term of equation $\big(1\big)$ we have

$$\epsilon\pmb{q_0}\vec{v}\pmb{q_{0}^{*}} = \epsilon\vec{v}$$

Thus this quaternion product has no rotational effect on vector $\vec{v}$ and equation $\big(1\big)$ becomes:

$$1 + 2\epsilon\vec{q}_{\epsilon} + \epsilon\vec{v}\tag{2}$$

which is a dual quaternion representation of the resultant of $\vec{v}$ added to the vector associated with $2\vec{q}_{\epsilon}$. In other words, a translation of the point $\vec{v}$ in direction $\vec{q}_{\epsilon}$ by distance $\Vert 2\vec{q}_{\epsilon} \Vert$. If the translation vector is $\vec{d} = x_{d}\vec{i} + y_{d}\vec{j} + z_{d}\vec{k}$ then we can correct the translation distance doubling in our dual quaternion term $\big(\pmb{q_0} + \epsilon\pmb{q_{\epsilon}}\big)$ by using half the length of $\vec{d}$:

$$\begin{align} \big(1 + \frac{\epsilon}{2}\vec{d}\big)\big(1 + \epsilon\vec{v}\big)\big(1 - \frac{\epsilon}{2}\vec{d^{*}}\big) &= \big(1 + \epsilon\vec{v} + \frac{\epsilon}{2}\vec{d}\big)\big(1 - \epsilon\vec{d^{*}}\big) \\ &= 1 - \frac{\epsilon}{2}\vec{d^{*}} + \epsilon\vec{v} + \frac{\epsilon}{2}\vec{d} \\ &= 1 + \epsilon\vec{d} + \epsilon\vec{v} \end{align}$$

Therefore unit dual quaternion for a translation $\pmb{\hat{t}}$ is:

$$\pmb{\hat{t}} = 1 + \frac{\epsilon}{2}\vec{d}\tag{3}$$

Now we perform a second dual quaternion product on $1 + \epsilon\vec{v}$ for the rotation on $\vec{v}$. Using the unit dual quaternion $\pmb{\hat{r}} = \pmb{r_0} + \epsilon(0)$, which means $\pmb{r_0}$ is a unit quaterion, gives:

$$\begin{align} \pmb{\hat{r}}\big( 1 + \epsilon\vec{v} \big) \pmb{\bar{\hat{r}}^{*}} &= \pmb{r_0}\big( 1 + \epsilon\vec{v} \big) \pmb{{r_0}^{*}} \\ &= 1 + \epsilon \pmb{r_0}\vec{v}\pmb{{r_0}^{*}} \end{align}$$

Combining the two products for translation then rotation gives the dual quaterion $\pmb{\hat{s}}$:

$$\begin{align} \pmb{\hat{s}} &= \pmb{\hat{r}}\pmb{\hat{t}} \\ &= \pmb{r_0}\big(1 + \frac{\epsilon}{2}\vec{d}\big) \\ &= \pmb{r_0} + \frac{\epsilon}{2}\pmb{r_0}\vec{d}\tag{4} \end{align}$$

and it's conjugate

$$\begin{align} \pmb{\bar{\hat{s}}^{*}} &= \pmb{\bar{\hat{t}}}^{*}\pmb{\bar{\hat{r}}}^{*} \\ &=\pmb{{r_0}^{*}} - \frac{\epsilon}{2}\vec{d}^{*}\pmb{{r_0}^{*}}\tag{5} \end{align}$$

Applying the quaternion product with $\pmb{\hat{s}}$ to vector $\vec{v}$:

$$\begin{align} \pmb{\hat{s}}\big( 1 + \epsilon\vec{v}\big)\pmb{\bar{\hat{s}}^{*}} &= \big(\pmb{r_0} + \frac{\epsilon}{2}\pmb{r_0}\vec{d}\big)\big( 1 + \epsilon\vec{v}\big)\big(\pmb{{r_0}^{*}} - \frac{\epsilon}{2}\vec{d}^{*}\pmb{{r_0}^{*}}\big) \\ &= \big(\pmb{r_0} + \epsilon\pmb{r_0}\vec{v} + \frac{\epsilon}{2}\pmb{r_0}\vec{d}\big)\big(\pmb{{r_0}^{*}} - \frac{\epsilon}{2}\vec{d}^{*}\pmb{{r_0}^{*}}\big) \\ &= 1 - \frac{\epsilon}{2}\pmb{r_0}\vec{d}^{*}\pmb{{r_0}^{*}} + \epsilon\pmb{r_0}\vec{v}\pmb{{r_0}^{*}} + \frac{\epsilon}{2}\pmb{r_0}\vec{d}\pmb{{r_0}^{*}} \\ &= 1 + \epsilon\pmb{r_0}\big(\vec{v} + \frac{\vec{d}}{2} - \frac{\vec{d}^{*}}{2} \big)\pmb{{r_0}^{*}} \end{align}$$

However, $\vec{d}$ is a pure regular quaternion, so

$$ -\vec{d}^{*} = \vec{d}$$

Therefore

$$\pmb{\hat{s}}\big( 1 + \epsilon\vec{v}\big)\pmb{\bar{\hat{s}}^{*}} = 1 + \epsilon\pmb{r_0}\big(\vec{v} + \vec{d}\big)\pmb{{r_0}^{*}}\tag{6}$$

If we reverse the order of the operations and perform a rotation then translation, we get:

$$\begin{align} \pmb{\hat{s}}\big( 1 + \epsilon\vec{v}\big)\pmb{\bar{\hat{s}}^{*}} &= \big(\pmb{r_0} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\big)\big( 1 + \epsilon\vec{v}\big)\big( \pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{{r_0}^{*}}\vec{d}^{*}\big) \\ &= \big(\pmb{r_0} + \epsilon\pmb{r_0}\vec{v} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\big)\big( \pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{{r_0}^{*}}\vec{d}^{*}\big)\\ &= \pmb{r_0}\pmb{{r_0}^{*}} - \frac{\epsilon}{2}\pmb{r_0}\pmb{{r_0}^{*}}\vec{d}^{*} + \epsilon\pmb{r_0}\vec{v}\pmb{{r_0}^{*}} + \frac{\epsilon}{2}\vec{d}\pmb{r_0}\pmb{{r_0}^{*}}\\ &= 1 + \epsilon\big(\pmb{r_0}\vec{v}\pmb{{r_0}^{*}} + \vec{d}\big)\tag{7} \end{align}$$

We can modify the regular unit quaternion $\pmb{r_0} = r_0 + \vec{r}$ into one that uses angles of rotation around the axis $\vec{r}$. See Extracting the Cross and Dot Products from the Quaternion Rotation Operator. The scalar part is $\cos{\Big(\frac{\theta}{2}\Big)}$ and the vector part is the unit vector $\vec{u}$ of $\vec{r}$ scaled by $\sin{\Big(\frac{\theta}{2}\Big)}$.

$$\pmb{r_0} = \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{u}\tag{8}$$

Substituting $(8)$ into $(4)$:

$$\begin{align} \pmb{\hat{s}} &= \pmb{r_0} + \frac{\epsilon}{2}\pmb{r_0}\vec{d} \\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{u} + \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{u} \bigg)\vec{d} \\ &= \cos{\Big(\frac{\theta}{2}\Big)} + \sin{\Big(\frac{\theta}{2}\Big)}\vec{u} + \frac{\epsilon}{2}\bigg( \cos{\Big(\frac{\theta}{2}\Big)}\vec{d} + \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{u}\times\vec{d}\Big) - \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{u}\cdot\vec{d}\Big) \bigg)\tag{9} \end{align}$$

Likewise, substituting $(8)$ into $(5)$:

$$\begin{align} \pmb{\hat{s}} &= \pmb{{r_0}^{*}} - \frac{\epsilon}{2}\vec{d}^{*}\pmb{{r_0}^{*}} \\ &= \cos{\Big(\frac{\theta}{2}\Big)} - \sin{\Big(\frac{\theta}{2}\Big)}\vec{u} - \frac{\epsilon}{2} \bigg(\cos{\Big(\frac{\theta}{2}\Big)}\vec{d}^{*} - \sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{d}^{*} \times \vec{u}\Big) +\sin{\Big(\frac{\theta}{2}\Big)}\Big(\vec{d}^{*}\cdot\vec{u}\Big)\bigg)\tag{10} \\ \end{align}$$

Monday, December 23, 2019

How To Represent A 3D Vector As A Unit Dual Qauternion

To see how any $3D$ vector $\vec{v} = \big(a, b, c\big)$ can be represented as a unit dual quaternion, let's start with the dual quaternion $\pmb{\hat{q}} = \pmb{q_0} + \epsilon\pmb{q_{\epsilon}}$ with quaternions components $\pmb{q_0}$ and $\pmb{q_{\epsilon}}$. The real and imaginary parts of $\pmb{q_0}$ and $\pmb{q_{\epsilon}}$ are given as follows with the imaginary part italicized and an arrow above:

$$\begin{align} \pmb{q_0} &= w_0 + \vec{q}_{0} = w_0 + \big(x_0\vec{i} + y_0\vec{j} + z_0\vec{k}\big)\\ \pmb{q_{\epsilon}} &= w_{\epsilon} + \vec{q}_{\epsilon} = w_{\epsilon} + \big(x_{\epsilon}\vec{i} + y_{\epsilon}\vec{j} + z_{\epsilon}\vec{k} \big) \end{align}$$

Their respective conjugates are:

$$\begin{align} \pmb{q_{0}^{*}} &= w_0 - \vec{q}_{0} = w_0 - \big(x_0\vec{i} + y_0\vec{j} + z_0\vec{k}\big)\\ \pmb{q_{\epsilon}^{*}} &= w_{\epsilon} - \vec{q}_{\epsilon} = w_{\epsilon} - \big(x_{\epsilon}\vec{i} + y_{\epsilon}\vec{j} + z_{\epsilon}\vec{k} \big) \end{align}$$

Unlike regular quaternions, there are three different conjugations of dual quaternions which depend on whether:

  1. The dual number is conjugated

    $$\pmb{\bar{\hat{q}}} = \pmb{q_0} - \epsilon\pmb{q_{\epsilon}}$$

    This finds little use except in deriving the third type of conjugation $\pmb{\bar{\hat{q}}^{*}}$.

  2. The quaternion components are conjugated

    $$\pmb{\hat{q}^{*}} = \pmb{q_{0}^{*}} + \epsilon\pmb{q_{\epsilon}^{*}}$$

    The result of $\pmb{\hat{q}}\pmb{\hat{q}^{*}}$ is a dual scalar but it can be just a regular scalar when the dot-product $\pmb{q_{0}} \cdot \pmb{q_{\epsilon}} = 0$ (i.e. when $\pmb{q_{0}}$ and $\pmb{q_{\epsilon}}$ are orthogonal 4-tuples).

  3. The dual number and quaternion components are both conjugated.

    $$\pmb{\bar{\hat{q}}^{*}} = \pmb{q_{0}^{*}} - \epsilon\pmb{q_{\epsilon}^{*}}$$

    The product $\pmb{\hat{q}}\pmb{\bar{\hat{q}}^{*}}$ is a dual quaternion whose real part is a scalar and dual part is a vector.

The conjugate $\pmb{\hat{q}^{*}} = \pmb{q_{0}^{*}} + \epsilon\pmb{q_{\epsilon}^{*}}$ is used to define the norm of $\pmb{\hat{q}}$:

$$\begin{align} \Vert \pmb{\hat{q}} \Vert &= \sqrt{\pmb{\hat{q}\hat{q}^{*}}} \\ &= \sqrt{\big(\pmb{q_0} + \epsilon\pmb{q_{\epsilon}}\big)\big(\pmb{q_{0}^{*}} + \epsilon\pmb{q_{\epsilon}^{*}}\big)} \\ &= \sqrt{\pmb{q_0q_{0}^{*}} + \epsilon\big(\pmb{q_0q_{\epsilon}^{*}} + \pmb{q_{\epsilon}q_0^{*}}\big)} \\ &= \sqrt{\pmb{q_0q_{0}^{*}} + 2\epsilon\big(\pmb{q_0} \cdot \pmb{q_{\epsilon}}\big)} \end{align}$$

where

$$\begin{align} \pmb{q_0q_{0}^{*}} &= \big(w_0 + x_0\pmb{i} + y_0\pmb{j} + z_0\pmb{k}\big)\big( w_0 - x_0\pmb{i} - y_0\pmb{j} - z_0\pmb{k}\big) \\ &= w_0^2 + x_0^2 + y_0^2 + z_0^2 \end{align}$$

and

$$\begin{align} \pmb{q_0q_{\epsilon}^{*}} + \pmb{q_{\epsilon}q_0^{*}} &= 2\big(w_0 w_{\epsilon} + x_0 x_{\epsilon} + y_0 y_{\epsilon} + z_0 z_{\epsilon} \big) \\ &= 2\big(\pmb{q_0} \cdot \pmb{q_{\epsilon}}\big) \end{align}$$

A unit dual quaternion has a norm $\Vert \pmb{\hat{q}} \Vert = 1$. Choosing $\pmb{q_0}$ and $\pmb{q_{\epsilon}}$ to be orthogonal makes the dot-product $\pmb{q_0} \cdot \pmb{q_{\epsilon}} = 0$ which then leaves us with $\sqrt{\pmb{q_0q_{0}^{*}}} = 1$ and therefore $w_0^2 + x_0^2 + y_0^2 + z_0^2 = 1$. Choosing $\vec{q}_{0} = 0$, $\mathrm{q_{\epsilon}} = 0$ and the coefficients of $\vec{q}_{\epsilon}$ to be $\big(a, b, c\big)$ of vector $\pmb{v}$ satisfies the conditions of the $\pmb{q_0} \cdot \pmb{q_{\epsilon}} = 0$ and $w_0^2 + x_0^2 + y_0^2 + z_0^2 = 1$:

$$w_0 w_{\epsilon} + x_0 x_{\epsilon} + y_0 y_{\epsilon} + z_0 z_{\epsilon} = w_0(0) + (0)a + (0)b + (0)c = 0$$
$$w_0^2 + x_0^2 + y_0^2 + z_0^2 = w_0^2 + (0)^2 + (0)^2 + (0)^2 = w_0^2$$ $$w_0^2 = 1$$

Thus $w_0 = 1$ and the vector $\vec{v} = \big(a, b, c\big)$ is encoded in a dual quaternion as:

$$\begin{align} &1 + \epsilon\big( a\vec{i} + b\vec{j} + c\vec{k} \big) \\ &1 + \epsilon\vec{v} \end{align}$$