Unit dual quaternion

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

Bases: DualQuaternion

[summary]

Parameters:

DualQuaternion ([type]) – [description]

Warning

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

Seealso:

UnitDualQuaternion()

classmethod Pure(x)
Return type:

Self

SE3()[source]

Convert unit dual quaternion to SE(3) matrix

Returns:

SE(3) matrix

Return type:

SE3

Example:

>>> from spatialmath import UnitDualQuaternion, SE3
>>> T = SE3.Rand()
>>> print(T)
  -0.3891    0.3705   -0.8434    0.2927    
   0.4336    0.8815    0.1871    0.7899    
   0.8128   -0.2929   -0.5036   -0.8027    
   0         0         0         1
>>> d = UnitDualQuaternion(T)
>>> print(d)
-0.4972 <<  0.2414,  0.8328, -0.0317 >> + ε -0.3770 <  0.2490, -0.2886,  0.2261 >
>>> print(d.SE3())
  -0.3891    0.3705   -0.8434    0.2927    
   0.4336    0.8815    0.1871    0.7899    
   0.8128   -0.2929   -0.5036   -0.8027    
   0         0         0         1
__add__(right)

Sum of two dual quaternions

Returns:

Product

Return type:

Self

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]

Create new unit dual quaternion

Parameters:
  • UnitDualQuaternion(real, dual) is a new unit dual quaternion with real and dual parts as specified.

  • UnitDualQuaternion(T) is a new unit dual quaternion equivalent to the rigid-body motion described by the SE3 value T.

Example:

>>> from spatialmath import UnitDualQuaternion, SE3
>>> T = SE3.Rand()
>>> print(T)
  -0.9959    0.07085  -0.05645   0.7553    
  -0.01502  -0.7436   -0.6685    0.7442    
  -0.08934  -0.6649    0.7416   -0.1067    
   0         0         0         1
>>> d = UnitDualQuaternion(T)
>>> print(d)
-0.0230 << -0.0391, -0.3573,  0.9329 >> + ε  0.1975 <  0.3194, -0.3588, -0.1192 >
>>> type(d)
<class 'spatialmath.DualQuaternion.UnitDualQuaternion'>

The dual number is stored internally as two quaternion, respectively called real and dual. For a unit dual quaternion they are respectively:

\[ \begin{align}\begin{aligned}\q_r &\sim \mat{R}\\q_d &= \frac{1}{2} q_t \q_r\end{aligned}\end{align} \]

where \(\mat{R}\) is the rotational part of the rigid-body motion and \(q_t\) is a pure quaternion formed from the translational part \(t\).

__mul__(right)

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)

Difference of two dual quaternions

Returns:

Product

Return type:

Self

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()

Conjugate of dual quaternion

Returns:

Conjugate

Return type:

Self

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()

Dual quaternion as a matrix

Returns:

Matrix represensation

Return type:

ndarray[Tuple[Literal[8], Literal[8]], dtype[floating]]

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()

Norm of a dual quaternion

Returns:

Norm as a dual number

Return type:

Tuple[float, float]

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: ndarray[Tuple[Literal[8]], dtype[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])