Skip to content

About quaternions🔗

About quaternions and dual quaternions🔗

Quaternions are an extension of the complex numbers. The set of quaternions is given by

\[\{w + x \cdot i + y \cdot j + z \cdot k \;|\; w, x , y, z \in \mathbb{R} \}\]

A dual quaternion \(\hat{q} = q_{r} + \varepsilon q_{d}\) consists of the two quaternions \(q_{r}\) and \(q_{d}\), where \(q_{r}\) is the real part, \(q_{d}\) is the dual part, and \(\varepsilon\) is the dual unit number (\(\varepsilon^2=0\)).

Properties of quaternions🔗

Each quaternion \(q=w+ix+jy+kz\) consists of the scalar part \(w\) and the vector part \({\mathbf v}=(x,y,z)\), where \((1,i,j,k)\) are the basis elements of the quaternion vector space. In HALCON, quaternions are represented by a tuple containing four elements: \([w, x, y, z]\).

The conjugation of a quaternion \(q = w+ix+jy+kz\) is given by \(\bar{q} = w - xi - yj - zk\).

A quaternion is a unit quaternion if its norm is 1. Unit quaternions can be used to describe rotations. A counterclockwise rotation around an unit vector \({\mathbf v}\) by an angle \(\alpha\) can be described by the unit quaternion \(q =(\cos(\alpha/2), \sin(\alpha/2) \, {\mathbf v})\).
The rotation of a point \(\mathbf r\) by a unit quaternion \(q\) is given by \(r' = q {\mathbf r} \bar{q}\).
\(\mathbf r\) will be transformed into quaternion form to perform the rotation. This is done by setting the real part to zero and the three imaginary components to the three components of \(\mathbf r\).

The product of two quaternions \(p\) and \(q\) is defined as:

\[\begin{eqnarray*} \begin{array}{rcl} pq &=& (w_p w_q - x_p x_q - y_p y_q - z_p z_q) \\ &+& (w_p x_q + x_p w_q + y_p z_q - z_p y_q)\, i\\ &+& (w_p y_q - x_p z_q + y_p w_q + z_p x_q)\, j\\ &+& (w_p z_q + x_p y_q - y_p x_q + z_p w_q)\, k\\ \end{array} \end{eqnarray*}\]

As a consequence, the multiplication of two quaternions is not commutative, that is, \(pq \neq qp\).

Representing dual quaternions in HALCON🔗

In HALCON, a dual quaternion is represented by a tuple with eight values \([w_{r}, x_{r}, y_{r}, z_{r}, w_{d}, x_{d}, y_{d}, z_{d}]\), where \(w_{r}\) and \({\mathbf v}_{r} = (x_{r},y_{r},z_{r})\) are the scalar and the vector part of the real part, and \(w_{d}\) and \({\mathbf v}_{d} = (x_{d},y_{d},z_{d})\) are the scalar and the vector part of the dual part.

Transformations using dual quaternions and Plücker coordinates🔗

Dual quaternions🔗

In contrast to unit quaternions, which are able to represent 3D rotations, a unit dual quaternion is able to represent a full 3D rigid transformation, that is, a 3D rotation and a 3D translation. Hence, unit dual quaternions are an alternative representation to 3D poses and 3D homogeneous transformation matrices for 3D rigid transformations. In comparison to transformation matrices with 12 elements, dual quaternions with 8 elements are a more compact representation. Similar to transformation matrices, dual quaternions can be combined easily to concatenate multiple transformations. Furthermore, they allow a smooth interpolation between two 3D rigid transformations and an efficient transformation of 3D lines.

A dual quaternion \(\hat{q} = q_r + \epsilon * q_d\) consists of the two quaternions \(q_r\) and \(q_d\), where \(q_r\) is the real part, \(q_d\) is the dual part, and \(\epsilon\) is the dual unit number \((\epsilon^2 = 0)\). Each quaternion \(q = w + ix + jy + kz\) consists of the scalar part \(w\) and the vector part \(v = (x,y,z)\), where \((1,i,j,k)\) are the basis elements of the quaternion vector space.

In HALCON, a dual quaternion is represented by a tuple with eight values \([w_r,x_r,y_r,z_r,w_d,x_d,y_d,z_d]\), where \(w_r\) and \(v_r = (x_r,y_r,z_r)\) are the scalar and the vector part of the real part and \(w_d\) and \(v_d = (x_d,y_d,z_d)\) are the scalar and the vector part of the dual part.

Each 3D rigid transformation can be represented as a screw (see and :

Figure 1: A 3D rigid transformation defined by a rotation and a translation (left) can be represented as a screw (right).

Figure 2: Moment \(M\) of the screw axis.

The parameters that fully describe the screw are:

  • screw angle \(\theta\)

  • screw translation \(d\)

  • direction \(L = (L^x, L^y, L^z)^T\) of the screw axis with \(||L|| = 1\)

  • moment \(M = (M^x, M^y, M^z)^T\) of the screw axis with \(L*M = 0\)

A screw is composed of a rotation about the screw axis given by \(L\) and \(M\) by the angle \(\theta\) and a translation by \(d\) along this axis. The position of the screw axis is defined by its moment with respect to the origin of the coordinate system. \(M\) is a vector that is perpendicular to the direction of the screw axis \(L\) and perpendicular to a vector from the origin to a point \(P_0\) on the screw axis. It is calculated by the vector product \(M = P_0 \times L\).

Hence, \(M\) is the normal vector of the plane that is spanned by the screw axis and the origin. Note that \(P_0 = L \times M\) is the point on the screw axis \((L,M)\) with the shortest distance to the origin of the coordinate system. The elements of a unit dual quaternion are related to the screw parameters of the 3D rigid transformation as:

\[ \hat{q} = \begin{pmatrix} cos \frac{\theta}{2}\\ L sin \frac{\theta}{2} \end{pmatrix} + \epsilon \begin{pmatrix} \frac{-d}{2} sin \frac{\theta}{2} \\ M sin \frac{\theta}{2} + L \frac{d}{2} cos \frac{\theta}{2} \end{pmatrix} \]

Note that \(\hat{q}\) and \(-\hat{q}\) represent the same 3D rigid transformation. Further note that the inverse of a unit dual quaternion is its conjugate, that is, \(\hat{q}^{-1}=\bar{\hat{q}}\).

The conjugation of a dual quaternion \(\hat{q} = q_{r} + \varepsilon q_{d}\) is given by \(\bar{\hat{q}} = \bar{q}_{r} + \varepsilon \bar{q}_{d}\), where \(\bar{q}_{r}\) and \(\bar{q}_{d}\) are the conjugations of the quaternions \(q_{r}\) and \(q_{d}\).

The conjugation of a quaternion \(q = x_{0} + x_{1}i + x_{2}j + x_{3}k\) is given by \(\bar{q} = x_{0} - x_{1}i - x_{2}j - x_{3}k\).

3D lines und Plücker coordinates🔗

Plücker coordinates are a very useful representation of lines in 3D space.

A line in 3D space, as shown in , can be described by two points \(P_0\) and \(P_1\). However, this usage of arbitrary points comes with the disadvantage that the same line can be described in multiple ways. Another approach is to take the unit line direction \(L\) and the line moment \(M\). \(M\) is a vector that is perpendicular to the plane spanned by the origin, a point on the line, and the line direction \(L\). \(L\) and \(M\) define the line independent of the arbitrary line points. The six parameters of \(L\) and \(M\) are called the Plücker coordinates of the line.

From its definition, it holds that \(\|L\| = 1\) and \(L \cdot M = 0\), where \(\cdot\) denotes the dot product of two vectors.

Figure 3: A line in 3D space and its components.

Using Plücker coordinates, it is very simple and efficient to compute the distance \(D\) of a point \(P\) to a line: \(D = \| P \times L-M \|\).

Dual quarternions and Plücker coordinates🔗

Plücker lines can be transformed efficiently with rigid transformations using dual quaternions.

Lines in 3D can be represented by dual unit vectors. A dual unit vector can be interpreted as a dual quaternion with 0 scalar part. The 3D rigid transformation that is represented by a unit dual quaternion is easily related to the corresponding screw around a screw axis. The screw axis is defined by its direction \(L\) with \(\|L\|=1\) and its moment \(M\). \(L\) and \(M\) are exactly the Plücker coordinates.

Consequently, a line \(\hat{l}\) can be represented by a dual quaternion with 0 scalar part by

\[ \hat{l} = l_r + \epsilon l_d = \begin{pmatrix} 0 \\ L_x\\ L_y\\ L_z\\ \end{pmatrix} + \epsilon \begin{pmatrix} 0 \\ M_x\\ M_y\\ M_z\\ \end{pmatrix} \]

The line \(\hat{l}\) can be transformed by the 3D rigid transformation that is represented by the unit dual quaternion \(\hat{q}\) very conveniently:

\[ \hat{k} = \hat{q} \hat{l} $\bar{\hat{q}} \]

The resulting dual quaternion \(\hat{k}\) also has 0 scalar part and directly contains the direction and the moment of the transformed line in its vector part.