Dual Quaternion

class DualQuaternion(real=None, dual=None)[source]

Bases: object

A dual number is an ordered pair \(\hat{a} = (a, b)\) or written as \(a + \epsilon b\) where \(\epsilon^2 = 0\).

A dual quaternion can be considered as either:

  • a quaternion with dual numbers as coefficients

  • a dual of quaternions, written as an ordered pair of quaternions

The latter form is used here.

References

Warning

Unlike the other spatial math classes, this class does not (yet) support multiple values per object.

Seealso

UnitDualQuaternion()

classmethod Pure(x)[source]
Return type

Self

__add__(right)[source]

Sum of two dual quaternions

Returns

Product

Return type

DualQuaternion

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d + d
 2.0000 <  4.0000,  6.0000,  8.0000 > + ε  10.0000 <  12.0000,  14.0000,  16.0000 >
__init__(real=None, dual=None)[source]

Construct a new dual quaternion

Parameters
Raises

ValueError – incorrect parameters

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> print(d)
 1.0000 <  2.0000,  3.0000,  4.0000 > + ε  5.0000 <  6.0000,  7.0000,  8.0000 >
>>> d = DualQuaternion([1, 2, 3, 4,  5, 6, 7, 8])
>>> print(d)
 1.0000 <  2.0000,  3.0000,  4.0000 > + ε  5.0000 <  6.0000,  7.0000,  8.0000 >

The dual number is stored internally as two quaternion, respectively called real and dual.

__mul__(right)[source]

Product of dual quaternion

  • dq1 * dq2 is a dual quaternion representing the product of dq1 and dq2. If both are unit dual quaternions, the product will be a unit dual quaternion.

  • dq * p transforms the point p (3) by the unit dual quaternion dq.

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d * d
-28.0000 <  4.0000,  6.0000,  8.0000 > + ε -120.0000 <  32.0000,  44.0000,  56.0000 >
Return type

Self

__sub__(right)[source]

Difference of two dual quaternions

Returns

Product

Return type

DualQuaternion

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d - d
 0.0000 <  0.0000,  0.0000,  0.0000 > + ε  0.0000 <  0.0000,  0.0000,  0.0000 >
conj()[source]

Conjugate of dual quaternion

Returns

Conjugate

Return type

DualQuaternion

There are several conjugates defined for a dual quaternion. This one mirrors conjugation for a regular quaternion. For the dual quaternion \((p, q)\) it returns \((p^*, q^*)\).

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d.conj()
 1.0000 < -2.0000, -3.0000, -4.0000 > + ε  5.0000 < -6.0000, -7.0000, -8.0000 >
matrix()[source]

Dual quaternion as a matrix

Returns

Matrix represensation

Return type

ndarray(8,8)

Dual quaternion multiplication can also be written as a matrix-vector product.

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d.matrix()
array([[ 1., -2., -3., -4.,  0.,  0.,  0.,  0.],
       [ 2.,  1., -4.,  3.,  0.,  0.,  0.,  0.],
       [ 3.,  4.,  1., -2.,  0.,  0.,  0.,  0.],
       [ 4., -3.,  2.,  1.,  0.,  0.,  0.,  0.],
       [ 5., -6., -7., -8.,  1., -2., -3., -4.],
       [ 6.,  5., -8.,  7.,  2.,  1., -4.,  3.],
       [ 7.,  8.,  5., -6.,  3.,  4.,  1., -2.],
       [ 8., -7.,  6.,  5.,  4., -3.,  2.,  1.]])
>>> d.matrix() @ d.vec
array([ -28.,    4.,    6.,    8., -120.,   32.,   44.,   56.])
>>> d * d
-28.0000 <  4.0000,  6.0000,  8.0000 > + ε -120.0000 <  32.0000,  44.0000,  56.0000 >
norm()[source]

Norm of a dual quaternion

Returns

Norm as a dual number

Return type

2-tuple

The norm of a UnitDualQuaternion is unity, represented by the dual number (1,0).

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d.norm()  # norm is a dual number
(5.477225575051661, 11.832159566199232)
property vec: numpy.ndarray[Any, numpy.dtype[numpy.floating]]

Dual quaternion as a vector

Returns

Vector represensation

Return type

ndarray(8)

Example:

>>> from spatialmath import DualQuaternion, Quaternion
>>> d = DualQuaternion(Quaternion([1,2,3,4]), Quaternion([5,6,7,8]))
>>> d.vec
array([1, 2, 3, 4, 5, 6, 7, 8])