Dual Quaternions Algebra
Dual quaternions are a mathematical tool used to represent rigid transformations in 3D space, or more concretely, the special Euclidean space SE(3). They are an extension of quaternions, which are used to represent rotations. For more mathematical details, see books by Bottema and Roth[1], or Selig[2]. The geometrical basics are explained in Study’s Kinematics.
Dual quaternions are composed of two quaternions, one representing the rotation and the other representing the translation. It is an 8-dimensional vector space over the real numbers.
A dual quaternion \(\mathbf{p}\) is defined as:
where \(\mathbf{q}_p\) (primal) is the rotation quaternion, \(\mathbf{q}_d\) (dual) is the translation quaternion, and \(\epsilon\) is the dual unit with the property that \(\epsilon^2 = 0\).
There are two conventions how to write a dual quaternion, either using 1-line equation with \(\vec{i}, \vec{j}, \vec{k}\) imaginary basis, or 8-dimensional vector:
where \(p_0\) is the real part, \(p_1, p_2, p_3\) are the imaginary parts of the primal quaternion \(\mathbf{q}_p\), and the same applies for the dual quaternion \(\mathbf{q}_d = (p_4, p_5, p_6, p_7)\).
In the package, the class DualQuaternion is used to represent dual
quaternions. A simple example of creating an identity dual quaternion is:
from rational_linkages import DualQuaternion
p = DualQuaternion()
which will create a dual quaternion \(\mathbf{p} = (1, 0, 0, 0, 0, 0, 0, 0)\).
A dual quaternion has to fulfill so-called Study condition to be a proper rigid body transformation, i.e. it has to lie on Study Quadric. The Study condition is:
Dual Quaternion Norms, Conjugation, and Inversion
Except basic arithmetic operations like addition, scalar multiplication, and multiplication of two dual quaternions, there are several other operations that can be performed with dual quaternions.
DQ Conjugate
Method DualQuaternion.conjugate() returns the conjugate of a dual quaternion
\(\mathbf{p}\). It is defined as conjugation of both
quaternions \(\mathbf{q}_p\) and \(\mathbf{q}_d\):
DQ Epsilon Conjugate
Method DualQuaternion.eps_conjugate() returns the epsilon conjugate of a
dual quaternion \(\mathbf{p}\). It is defined as the negation of the dual part:
DQ Norm
Method DualQuaternion.norm() returns 8-tuple with the norm of a dual
quaternion \(\mathbf{p}\). The norm is sometimes called the quadrance, and
is defined as:
From the equation can be seen that the norm has primal and dual part. Therefore, the method mentioned above has the following shape:
Correspondence between Dual Quaternions and Transformation Matrices
A dual quaternion \(\mathbf{p} = (p_0, p_1, p_2, p_3, p_4, p_5, p_6, p_7)\) can be
mapped to a transformation matrix \(\mathbf{T}\) in SE(3) by the following equation.
The map is done by DualQuaternion.dq2matrix() and
TransfMatrix.matrix2dq() methods. The class TransfMatrix uses the
european convention for the transformation matrix, i.e., it has the form:
where \(\mathbf{R}\) is a 3x3 rotation matrix, and \(\mathbf{t}\) is a 3x1 translation vector. This is in contrast to the american convention, much more common in engineering:
The rotation matrix \(\mathbf{R}\) consists of three orthogonal unit vectors, called normal, orthogonal, and approach vectors, i.e.:
Often, it is convenient to use create a transformation matrix from Tait-Bryan angles,
also known as roll-pitch-yaw angles. The method TransfMatrix.from_rpy_xyz()
serves for this purpose. Conversion to dual quaternion is then straightforward,
as seen in the following example:
# Create a transformation matrix from Tait-Bryan angles and translation vector,
# and convert it to dual quaternion
from rational_linkages import TransfMatrix, DualQuaternion
from math import pi
# Identity/origin
T0 = TransfMatrix()
# Create a transformation matrix from Tait-Bryan angles and translation vector
T1 = TransfMatrix.from_rpy_xyz([pi / 2, 0, 0], [1, 2, 3])
# Create a transformation matrix from Tait-Bryan angles and translation vector,
# use degrees instead of radians
T2 = TransfMatrix.from_rpy_xyz([0, -90, 0], [4, 5, 6], unit='deg')
# Convert the transformation matrices to dual quaternions
T_list = [T0, T1, T2]
for T in T_list:
p = DualQuaternion(T.matrix2dq())
print("--------------------")
print("Transformation matrix:")
print(T)
print("Corresponding dual quaternion:")
print(p)
print("--------------------")
# Create TransfMatrix from DualQuaternion
p = DualQuaternion(T2.matrix2dq())
T = TransfMatrix(p.dq2matrix())
print(T)
Dual Quaternion Actions
The class dualQuaternionAction implements methods for performing actions
on points and lines in 3D space.
An action is transformation of a point or a line by given dual quaternion. In case of a general dual quaternion, it is a half-turn around a screw axis defined by the dual quaternion.
DQ Action on a Point
Points are described in Homogeneous Points.
An action of a dual quaternion \(\mathbf{p}\) on a point \(\mathbf{q}\) is defined as:
DQ Action on a Line
Lines are described in Normalized Lines
An action of a dual quaternion \(\mathbf{p}\) on a line \(\mathbf{l}\) is defined as:
DQ Action on a Plane
Planes are not supported by the package yet.
References: