0% found this document useful (0 votes)
73 views11 pages

Dual Quaternions

This document provides an overview of dual-quaternions and their applications in computer graphics, robotics, and animation. Dual-quaternions combine rotational and translational components into a single variable that can be interpolated and concatenated efficiently. They offer advantages over homogeneous transformation matrices such as increased computational efficiency and reduced overhead. The document explains that dual-quaternions build upon quaternion mathematics and dual number theory, so it reviews the basics of quaternions and dual numbers to establish understanding before exploring how dual-quaternions represent rigid transformations and can be used for tasks like interpolation.

Uploaded by

Matthew Fraser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views11 pages

Dual Quaternions

This document provides an overview of dual-quaternions and their applications in computer graphics, robotics, and animation. Dual-quaternions combine rotational and translational components into a single variable that can be interpolated and concatenated efficiently. They offer advantages over homogeneous transformation matrices such as increased computational efficiency and reduced overhead. The document explains that dual-quaternions build upon quaternion mathematics and dual number theory, so it reviews the basics of quaternions and dual numbers to establish understanding before exploring how dual-quaternions represent rigid transformations and can be used for tasks like interpolation.

Uploaded by

Matthew Fraser
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

Dual-Quaternions
From Classical Mechanics to Computer Graphics and Beyond

Ben Kenwright
www.xbdev.net
[email protected]

Abstract
This paper presents an overview of the analytical advantages of dual-quaternions and their potential in the areas of robotics,
graphics, and animation. While quaternions have proven themselves as providing an unambiguous, un-cumbersome,
computationally efficient method of representing rotational information, we hope after reading this paper the reader will
take a parallel view on dual-quaternions. Despite the fact that the most popular method of describing rigid transforms is
with homogeneous transformation matrices they can suffer from several downsides in comparison to dual-quaternions. For
example, dual-quaternions offer increased computational efficiency, reduced overhead, and coordinate invariance. We also
demonstrate and explain how, dual-quaternions can be used to generate constant smooth interpolation between transforms.
Hence, this paper aims to provide a comprehensive step-by-step explanation of dual-quaternions, and it comprising parts
(i.e., quaternions and dual-numbers) in a straightforward approach using practical real-world examples and uncomplicated
implementation information. While there is a large amount of literature on the theoretical aspects of dual-quaternions there
is little on the practical details. So, while giving a clear no-nonsense introduction to the theory, this paper also explains and
demonstrates numerous workable aspect using real-world examples with statistical results that illustrate the power and
potential of dual-quaternions.

Keywords: dual-quaternion, transformation, blending, interpolation, quaternion, dual-number

Introduction (Why should we use


 They are computationally efficient (comparable with
dual-quaternions?) matrices and quaternions) [2][3]
Dual-quaternions are a neat mathematical tool that breaks  They can be integrated into a current system with little
away from the norm. Probably one of their most important disruption (i.e., matrix alternative)
properties is in classical mechanics since they can  They present a single invariant coordinate frame to
represent complex problems in a unified compact way. A representation rigid transforms [4]
dual-quaternion combines the linear and rotational Dual-quaternions are an algorithmically simple and
components together into a single variable that can be computationally efficient approach of representing rigid
interpolated, concatenated and transformed using a single transforms (i.e., rotation and translation). They are used in
set of algebraic rules. While it has been demonstrated that the same way as quaternions but provide the added
quaternions are the best general solution for rotations [1] advantage of encapsulating both translation and rotation
they can only represent half the rigid transformation. into a unified state that can be concatenated and
Since, a full 3D rigid transformation is composed of a interpolated effortlessly. In fact, we believe that the reader
translational and rotational component, which is after reading this paper will be sufficiently familiar with
traditionally managed as a 4x4 homogenous matrix. how dual-quaternion algebra works, and how it can be
However, the matrix contains a great deal of overhead and used in practical situations, to begin to appreciate the
is difficult to interpolate between transforms. enormous potential dual-quaternions can offer, both for the
Alternatively, the transformations can be managed using graphical community but also in other areas of research.
two independent components (e.g., translation vector and a
quaternion). Therefore, dual-quaternions take us in a Overview (What we need to know)
different direction and present us with a unified component Dual-quaternions are a combination of dual-number theory
that presents us with a huge number of advantages. and quaternion mathematics. Whereby, to have a good
In a nutshell: understanding of how we can exploit dual-quaternions to
 They combine rotation and translation into a unified our advantage, we need to understand the basics of
state variable quaternions and dual-number theory. Hence, this paper
 They are a compact representation (8 scalars) begins by explaining the fundamental components of dual-
 They are easily converted to other forms (e.g., quaternions to help establish a common ground for readers,
matrices) after which, we then focus on dual-quaternions and the
 They can be interpolated easily without ambiguity or applicability for representing transformations both
gimbals' lock computationally and dynamically (e.g., calculating
differences and interpolating).

Ben Kenwright ([email protected]) (October 2012) pp 1-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

Basically, a dual-quaternion is the concatenation of it is essential to have a good understand of its underpinned
quaternion and dual-number theory (see Figure 1). parts work (i.e., quaternions and dual-numbers).
Furthermore, once the reader understands how quaternions
Quaternion Dual-Number
Mathematics Dual-Quaternions work, it should be trouble-free and straightforward to see
Theory how dual-quaternions operate due to their likeness.
Figure 1: Dual-Quaternions Components. A quaternion is represented by two fundamental parts, a
To avoid confusion and enable the reader to easily scalar real part (w) and an imaginary vector part (
distinguish a quaternion from a dual-quaternion we use v  x, y, z ). In practice we are only concerned with a unit-
two discernible symbols to identify them (see Equation 1). quaternion since they offer the most benefits and represent
the rotation on a 4D unit-hypersphere. While the majority
Quaternion (q) of people are familiar with the decomposition and
1
Dual  Quaternion ( ) principles of quaternions, there can, however, be a
deficiency in the practical considerations.

Quaternion
Real Complex

q = w + ix + jy + kz
Imaginary 4 scalar variables

Dual-Quaternion Real Dual-Part

= qr + qd
Dual-Operator
8 scalar variables
Figure 2: Visual Overview of Quaternion and Dual-Quaternion Components.

An overview of both the quaternion and dual-quaternion q=(w,x,y,z)=(w,v) 2


components is shown in Figure 2. While a quaternion
consists of four scalar values, a dual-quaternion consists of The fundamental mathematical operations are defined for
eight scalar values. However, a quaternion can only quaternions (i.e., addition and multiplication of quaternions
represent rotation, while a dual-quaternion can represent and the multiplication of a quaternion by a scalar).
both rotation and translation.
Dual-quaternions are a valuable tool that can be added to Quaternion from Axis-Angle
an individual's library to achieve a particular task, e.g., Given an angle and axis of rotation, we can construct a
rigid hierarchy concatenation, interpolation, character quaternion using Equation 3.
skinning. They operate similar to existing methods (i.e.,     
matrices) and can be transformed to and from other forms qˆ   cos   , nˆ sin   
 2  2 
easily (i.e., quaternions, matrices) which enables them to
or 3
be integrated or exchanged with little disruption into a
       
system to gain their rewards. For a beginners introduction qw  cos   , qx  nx sin   , q y  n y sin   , qz  nz sin  
to dual-quaternions with an emphasis on comparison 2 2 2 2
between diverse methods (e.g., matrices and Euler angles)
and how to go about implementing a straightforward where  is the angle and n̂ is a unit-vector representing
library I refer the reader to the paper by Kenwright [3]. the axis of rotation.
Quaternion Algebra While it is recommended that you consistently use
quaternions for rotation, we can, however, rewrite
While walking with his wife in 1843, Sir William
Equation 3 to give us the axis-angle from the quaternion to
Hamilton [5] gave birth to a revolutionary new concept
aid in visualizing angle-axis differences as shown in
that later became known as Quaternions. While it took
Equation 4.
some time for quaternions to be accepted, they eventually
demonstrated themselves as being the most competent,   2 cos 1 (qw )
memory efficient, ambiguity-free method of representing
rotations. Furthermore, since quaternions are the qx qy qz
nx  , ny  , nz  4
foundation upon which dual-quaternions are built it comes      
sin   sin   sin  
as no shock, and is quite understandable, that these 2 2 2
properties are inherited. Nevertheless, to ensure the reader
is truly able to understand the potential of dual-quaternions

Ben Kenwright ([email protected]) (October 2012) pp 2-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

In practice, if you do decide to convert to the axis-angle q0  q1  (q0w  q1w , q0 x  q1x , q0 y  q1y , q0 z  q1z ) 8
representation, you should ensure the quaternion is always
a unit-quaternion and be aware of the divide by zero
  Quaternion Multiplication
causality that may occur (i.e., sin   is zero).
2 Quaternion multiplication is analogous to matrix
multiplication; whereby, multiplying quaternions together
Quaternion Vector Transformation is equivalent to combining their transforms. For example,
when two quaternions are multiplied together it is
The quaternions transformation can be applied to a 3D
equivalent to the first quaternion being rotated by the axis
vector coordinate by means of multiplication. Whereby, to
and angle of the second quaternion. However, quaternion
transform a vector position by a quaternion we simply
multiplication is non-commutative (i.e., order of
convert the vector to a quaternion (i.e., the imaginary part
multiplication matters) but can be simplified by being
is the vector position, and the scalar real part zero) and
represented using the dot and cross product (shown in
multiply it by the quaternion transform and its conjugate,
Equation 9).
as shown in Equation 5. Optionally, we can convert the
quaternion transform to a matrix with little or no extra q0 q1  (qw0  q v 0 )(qw1  q v1 )
work for systems that operate with matrices (e.g., 9
 (qw0 qw1  q v 0  q v1 )  (qw0q v1  qw1q v 0  q v 0  q v1 )
transforms are done on the GPU using matrices).
ˆ ˆ 1
p '  qpq 5
where qw0 and qw1 represent the real scalar components of
where each quaternion and, q v 0 and q v1 represent the vector
 q̂ is a unit-quaternion representing the rotation component of each quaternion.
transform
Quaternion Difference
 q̂ 1 is a unit-quaternion that represents the inverse Since each quaternion represents an axis-angle, then
of the rotation quaternion multiplying two quaternions together is equivalent to
 p is the 3D vector point in quaternion form (i.e., transforming one quaternion by another. Hence, it should
p  (0, v) with v  (vx , vy , vz ) ) be obvious, that we can use this to determine differences
between quaternions. If both quaternions are the same, and
 p ' is the 3D transformed vector point in we multiply one by the inverse of itself, it will cancel out
quaternion form (i.e., p '  (0, v) ) (see Equation 10) and give us an identity quaternion.
However, it is extremely important to note that for a unit- ˆ ˆ 1  1
qq 10
quaternion the inverse is the same as the conjugate. This is
due to the mathematical and computational efficiency by So if we have two quaternions, we simply multiply one by
which the conjugate is calculated. The conjugate of a the inverse to get the difference between them (Equation
quaternion is simply the negation of the vector component 11). It is vital to remember that the inverse of a unit-
(shown in Equation 6). quaternion is the same as the conjugate.

q1  q*  (w, v) 6 qˆdiff  qˆ A qˆB 1 11

For example, a simplified numerical example of the


Quaternion to Matrix difference between two quaternions is shown in Equation
Due to the popularity of matrices, it is vital to be able to 12.
transform a quaternion to matrix form and vice-versa. A A :   0, nˆ  0, 0,1 
quaternion can be transformed to a matrix using little more B :    , nˆ  0, 0,1 
than multiplications and additions as shown in Equation 7.
 0  0 
qˆ A   cos   ,  0, 0,1  sin      1, 0, 0, 0 
1-2(y 2 +z 2 ) 2(xy+zw) 2(xz+yw)    2   2 
       
M q   2(xy+zw) 1-2(x 2 +z 2 ) 2(yz+xw)  7 qˆ B   cos   ,  0, 0,1  sin      0, 0, 0,1 
 2(xy+yw) 2(yz+xw) 1-2(x 2 +y 2 )   2  2  12
 
qˆ B*  qˆ B 1   0, 0, 0, 1 
where M q is a matrix equivalent of the quaternion q, and qˆdiff  qˆ A qˆ B 1   (1)(0)  (0, 0, 0)  (0, 0, 1),
x, y, z and w represent the elements of the quaternion. (1)(0, 0, 1)  (0)(0, 0, 0)  (0, 0, 0)  (0, 0, 1) 
  0, 0, 0, 1 
Quaternion Addition qˆdiff :    , nˆ  0, 0, 1 
Adding two quaternions together is accomplished by
To help visualize the result for the example in Equation 12,
simply summing the individual components together as
imagine comparing the difference between two scalar
shown in Equation 8.
numbers A and B (e.g., 0 and n). Then the difference, A-B

Ben Kenwright ([email protected]) (October 2012) pp 3-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

= (0 - n) = -n, which is analogous to what we calculated in developed and what we primarily make use of in this paper
the example. is the screw calculus that allows the unification of
translation and rotation.
Quaternion Spherical Linear Interpolation (SLERP) The definition and properties of a dual-number are given in
Quaternion spherical linear interpolation is the Equation 18. Dual-numbers are akin to complex numbers.
transformation along the surface of the 4D unit- However, whereas complex numbers have a real-part and
hypersphere. an imaginary-part and dual-numbers have a real-part and a
Starting with the well known exponential function from dual-part.
complex numbers it can be shown that in Equation 13.
z  r   d with  2  0 but   0 18
e  cos  i sin 
i
13
where  is known as the dual-operator, r is the real-part
Then we can equate our quaternion and represent it as an and, d the dual-part.
exponential given by Equation 14.
Dual-Number Addition
q  ev  cos   v sin  14
(rA   d A )  (rB   d B )  (rA  rB )   (d A  d B ) 19

where   and v is a unit vector (noting that v 2  1 ).
2 Dual-Number Multiplication
We can then write the quaternion in the form (Equation (rA   d A ) (rB   d B )  rA rB   rA d B   rB d A   2 d A d B

15):  rA rB   (rA d B  rB d A ) (remember  2  0) 20

qt  cos(t)  vˆ sin(t) 15
Dual-Number Division
Then the Slerp expression is given by Equation 16.
(rA   d A ) (rA   d A ) (rB   d B )

SLERP(q0 , q1 : t )  q0 (q01q1 )t 16 (rB   d B ) (rB   d B ) (rB   d B )
For example, let us consider two very simple cases when rA rB  (rB d A  rA d B )
 21
t=0 and t=1 (rB ) 2
t 0 rA rB rB d A  rA d B
  
q  cos(t )  v sin(t )
t rB 2 rB 2
q 0  cos(0)  v sin(0)
Dual-Number Differentiation
q0  1
From elementary calculus principles shown in Equation
q0 (q0 1q1 )t  q0 (q0 1q1 )0  q0 (1)  q0 22.
and d s ( x   x )  s( x )
t 1 s( x)  lim 22
dx  x  0 x
q t  cos(t )  v sin(t ) We use Taylor series to find the differentiable (Equation
q1  cos()  v sin() 23).
q0 (q0 1q1 )t  q0 (q0 1q1 )1  (q0 q0 1 )q1  (1)q1  q1 f (rA  d A )  f (rA ) 
f (rA )
d A 
f (rA )
( d A ) 2 
f (rA )
(d A )3  ...
1! 2! 3!
f (rA )
 f (rA )  d A  0  0  .... (as,  2  0) 23
An alternative, and more popular, representation of 1!
Equation 16 can be calculated using a geometric approach  f (rA )  f (rA )d A

and is shown in Equation 17 (for a more detailed


description see Shoemake [1]).
Remarkably, due to the condition  2  0 , we end up with
sin  (1  t )  sin(t ) an extremely elegant solution.
SLERP(q0 , q1 : t )  q0  q1 17
sin( ) sin( ) For a more in-depth explanation of the rationale behind
dual-number theory see Keler [10] or Pennestr et al [11].
Dual-Number Theory Dual-Quaternion Algebra
Clifford [6] published his intriguing work on dual-numbers
The dual-quaternion is an extension of dual-number theory
in 1873, and provided us with a powerful tool for
whereby the numbers for the dual-number equation are
facilitating the analysis of complex systems (e.g.,
represented by quaternions. Remarkably, the dual-
mechanical, geometric). In fact, it was not long before
quaternion algebra that results is very straightforward and
they found a place in the movement of rigid bodies [7][8]
elegant and provides us an algebraically compact and
and later in geometry [9]. The relevant formalism that was

Ben Kenwright ([email protected]) (October 2012) pp 4-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

efficient system for solving otherwise complex problems. quaternion that possesses both the translation and rotation
For example, we can represent a rigid transforms with components; however, be aware that the multiplication
eight scalar variables; we can combine transforms order is important.
effortlessly through concatenation, and we are able to
produce smooth constant interpolation between rigid Dual-Quaternion to Position and Rotation
transformations. As shown in Figure 2, the dual- We can extract the position and rotation from a dual-
quaternion is decomposed into two parts the real part and quaternion. In reverse to Equation 25 that created a dual-
the dual-part. quaternion from a position and rotation, we conversely
extract the position and rotation using Equation 29.
Dual-Quaternion Identity
The identity of a dual-quaternion is shown in Equation 24   qr  q d
and is analogous to a quaternion identity. Therefore, any r  qr 29
dual-quaternion that is multiplied with an identity dual- t  2 qd qr *

quaternion remains unchanged. To define an identity dual-


quaternion we set the first scalar value to 1 and the other
seven scalar values are all 0. Dual-Quaternion Addition
The addition of dual-quaternions is one of the simplest
  [1,0,0,0][0,0,0,0] 24 operations since we only need to add each individual
component together (see Equation 30).
Dual-Quaternion from Position and Rotation  A  (a0  a1i  a2 j  a3 k )  (a4  a5i  a6 j  a7 k )
To construct a unit-dual quaternion from a rotation and a  B  (b0  b1i  b2 j  b3 k )  (b4  b5i  b6 j  b7 k )
translation we use Equation 25. We construct the dual-
quaternion from a pair of quaternions that represent the  A   B  ((a0  b0 )  (a1  b1 )  (a2  b2 )  (a3  b3 ))  30
rotation and translation. ((a4  b4 )  (a5  b5 )  (a6  b6 )  (a7  b7 ))
  qr  qd
qr  r Dual-Quaternion Multiplication
25
1
qd  t r Due to dual-numbers requiring  2  0 results in the
2 multiplication of dual-quaternions being a very neat and
where r is a unit quaternion representing the rotation and t tidy operation (see Equation 31). Hence, the resulting
is a quaternion describing the translation. The individual dual-quaternion multiplication can be broken down into
elements of the two quaternions from Equation 25 are three quaternion multiplications and a quaternion addition
shown in Equation 26. operation.

     A  q0  q1
r  [cos( ), n x sin( ), n y sin( ), n z sin( ) ]
2 2 2 2 26  B  q2  q3
31
t  [0, t x , t y , t z ]  A   B  (q0  q1 )(q2  q3 )
 q0 q2  (q0 q3  q1q2 )

where n is the axis of rotation,  is the angle of rotation,


Dual-Quaternion Conjugate
and t x , t y , t z is the position in Cartesian coordinates.
The dual-quaternion conjugate is essentially an extension
For example, if we want to construct a dual-quaternion that of the quaternion conjugate, and is given by Equation 32.
only has a rotation we have:
 *  q*   q* 32
   
  [cos( ), n x sin( ), n y sin( ), n z sin( ) ][0,0,0,0]
2 2 2 2 27
Dual-Quaternion Magnitude
A dual-quaternion multiplied by its conjugate gives the
and, if we want to construct a dual-quaternion that only has magnitude squared and hence the square root of this is the
a translation we have: scalar magnitude length (see Equation 33).
tx t y tz
  [1,0,0,0][0, , , ] 28 ||  ||  * 33
2 2 2
It is crucial to note that a unit dual-quaternion has a
Comparable to matrices and quaternions we can
magnitude of 1. Hence, we can say that the magnitude of a
concatenate dual-quaternion transformations using
unit dual-quaternion multiplied by its conjugate must equal
multiplication. Hence, you can create a pure rotation dual-
1.
quaternion and a pure translation dual-quaternion and
multiply them together to form a combined dual-

Ben Kenwright ([email protected]) (October 2012) pp 5-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

|| ˆ || || 
ˆˆ* ||  1 34 dual  quaternion  screw parameters
  2 cos 1 ( wr )
Dual-Quaternion Vector Transformation 1
d  2 wd
Equivalent to a quaternion a dual-quaternion can transform vr vr
a 3D vector coordinate as shown in Equation 34. Note that 37
for a unit-quaternion the inverse is the same as the  1 
l  vr  
conjugate.  v v 
 r r 
p '  ˆ pˆ 1 35  d wr  1
m   vd  l
where  2  v r v r
  is a dual-quaternion representing the transform and
  is a dual-quaternion that is the inverse of the dual-
1
screw parameters  dual  quaternion
quaternion   
 p is a dual-quaternion representing the rigid wr  cos  
2
transform (e.g., 3D vector point
 
p  (1,0,0,0)   (0, vx , vy vz ) ) v r  l sin  
2 38
 p ' is a dual-quaternion with the resulting transform. d  
wd   sin  
Plücker Coordinates
2 2
  d  
Plücker coordinates [12] are used to create Screw v d  sin   m  cos   l
coordinates which are an essential technique of  
2 2 2
representing lines. We need the Screw coordinates so that
we can re-write dual-quaternions in a more elegant form to Dual-Quaternion Power
aid us in formulating a neater and less complex
We can write the dual-quaternion representation in the
interpolation method that is comparable with spherical
form given in Equation 39 (see Daniilidis [14] for details).
linear interpolation for classical quaternions.
The Definition of Plücker Coordinates:  d   d 
ˆ  cos    ( l   m) sin  
1. p is a point anywhere on a given line  2   2 
39
2. l is the direction vector  ˆ   ˆ 
 cos    vˆ sin  
3. m = p  l is the moment vector 2 2
4. ( l , m) are the six Plücker coordinate where
We can convert the eight dual-quaternions parameters to  ˆ is a unit dual-quaternion
an equivalent set of eight screw coordinates and vice-versa.
The definition of the parameters are given in Equation 36.  v̂ is a unit dual-vector vˆ  l   m
 ˆ is a dual-angle ˆ     d
screw parameters  ( , d , l , m)
The dual-quaternion in this form is exceptionally
dual  quaternion  qr   qd 36 interesting and valuable as it allows us to calculate a dual-
 ( wr  v r )   ( wd  v d ) quaternion to a power. Calculating a dual-quaternion to a
power is essential for us to be able to easily calculate
where in addition to l representing the vector line direction spherical linear interpolation. However, instead of purely
and m the line moment, we also have d representing the rotation as with classical quaternions, we are instead now
translation along the axis (i.e., pitch) and the angle of able to interpolate full rigid transformations (i.e., rotation
rotation  . and translation) by using dual-quaternions.
Converting to and from a dual-quaternion and its screw  ˆ   ˆ 
parameters is shown in Equation 37 and Equation 38 (see ˆt  cos  t   vˆ sin  t  40
Daniilidis [13] for details).  2  2

Dual-Quaternion Screw Linear Interpolation


(ScLERP)
ScLERP is an extension of the quaternion SLERP
technique, and allows us to create constant smooth
interpolation between dual-quaternions. Similar to

Ben Kenwright ([email protected]) (October 2012) pp 6-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

quaternion SLERP we use the power function to calculate (For example, see Listing 1 for a practical implementation
the interpolation values for ScLERP shown in Equation 41. example).

ScLERP(ˆA , ˆB : t )  ˆA (ˆA1ˆB )t 41


Alternatively, a fast approximate alternative to ScLERP
where ˆA and ˆB are the start and end unit dual-quaternion was presented by Kavan et al. [15] called Dual-Quaternion
and t is the interpolation amount from 0.0 to 1.0. Linear Blending (DLB). Furthermore, dual-quaternions
have gained a great deal of attention in the area of
The implementation of ScLERP involves first using character-based skinning. Since, a skinned surface
Equation 37 to convert the dual-quaternion parameters to approximation using a weighted dual-quaternion approach
screw parameters, so we can calculate the power function produces less kinking and reduced visual anomalies
with Equation 40. Afterwards, we use Equation 38 to compared to linear methods by ensuring the surface keeps
convert back to a dual-quaternion to complete the its volume (for example, see Figure 3).
calculation and give the resulting interpolated result.
Dual-quaternions eliminate skin collapsing artefacts and
screw parameters  ( , d , l , m) while they are slightly slower than the linear blended
dual  quaternion  qr   qd 42 skinning method they are, however, graphical processor
unit (GPU) friendly. Furthermore, they are simple to
 ( wr  v r )   ( wd  v d ) integrate into a 3D engine and cause very little disruption
Basic Un-Optimized Implementation Steps of ScLERP (for since the same rigging as standard linear blending skinning
can be used.
Weighting
Weight A 1.0 .... 1.0 1.0 1.0 1.0 0.7 0.5 0.3 0.0 0.0 0.0 .... 0.0
0.0 .... 0.0 0.3 0.5 0.7 1.0 .... 1.0 Weight B

Transform Transform
A B

Transform Transform
A A

Transform Transform
B B

Linear Dual-Quaternion
Figure 3: Visual comparison between linear and dual-quaternion weighting for vertex skinning.

Equation 41): Interpolation


1. Calculate Inverse of A (i.e., Conjugate of A) In general, one of the greatest advantages of using
2. Multiply Inv(A) and B quaternions and dual-quaternions over any other method is
3. Calculate Screw Parameters for result Inv(A)B their ability to interpolate smoothly between transforms.
4. Calculate to the power of Naively, two values can represent the start and end, and a
5. Convert screw parameters form back to the scalar constant represents the interpolation amount (scalar
classical dual-quaternion form ratio is from 0.0 to 1.0). For a straight-line vector we can
6. Multiply with A to get the answer treat each component separately and use a parametric
equation shown in Equation 43. This has the added
advantage of being computationally fast and simple.

Ben Kenwright ([email protected]) (October 2012) pp 7-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

LERP(a, b : t )  b  (a  b)t 43 
greater than then the interpolation will take the "longest
2
where a and b represent the start and end value and t the path". We can detected easily in practice by taking the dot
in-between ratio. produce of the two quaternions (for a dual-quaternion we
In fact, for small changes we can use Equation 43 to use the quaternion for the rotation). If the dot product is
interpolate between quaternions and dual-quaternions. less than zero then the longest path will be taken.
However, as the quaternion and dual-quaternion become However, if we want to prevent the longest path from
more dissimilar there is a greater error and the intermediate being taken we simply negate all the elements for the
steps become less smooth and less correct. The quaternion or dual-quaternion before interpolating.
intermediate steps between the start and end do not Likewise, if we desire the longest path we can check that
represent a unit-quaternion rotation or dual-quaternion the dot product is greater than zero before negating the
rotation. Hence, we need to re-normalize the value at each quaternion or dual-quaternion.
step to ensure it falls on the unit-hypersphere. Most
importantly, though, is that the interpolation rate is not
Catmull-Rom Spline-Based Interpolation
constant. We can reduce the error and make the linear For irregular spaced key-frame data, we can exploit the
interpolation approximation more tolerable by normalizing Catmull-Rom spline-based vector interpolation function
the values between steps. This is known as Normalized and dual-quaternions algebra as a method for generating a
Linear Interpolation (NLERP) and has the added advantage unified, smooth, continuous trajectory path.
of ensuring that the intermediate values are always of unit-
length (see Equation 44). Again, it should be stressed that
Eradication of the Square Root
the linear interpolation approximation is only suitable for We can optimize some operations by eradicating the
small changes. square root overhead. Since both quaternions and dual-
quaternions are normalized the same way as vectors (see
qA + (qB - qA )t Equation 45), we can identify cases whereby an element is
NLERP(q A , qB : t )  44
|| qA + (qB - qA )t || multiplication with another element to cancel out the
square root.
where a is the start, b is the end and t is the interpolation
q q
amount (i.e., 0.0 to 1.0). qˆ   45
While it has numerous problems for both quaternions and || q || qq
dual-quaternions, it is computationally fast and easy to
However, the multiplication of two quaternion elements
implement and can, however, give reasonably good
results in the square root being redundant. For example,
approximations for small interpolations. The trouble is,
when we construct a matrix from a quaternion (as shown in
quaternions and dual-quaternions do not travel along
Equation 7) we multiply pairs of elements. This can be
straight-line trajectories. However, we can use an
used to cancel out the necessity to normalize the result as
alternative interpolation method that follows the unit-
shown in Equation 46.
hypersphere sphere. This is accomplished by interpolation
along the unit-hypersphere to produce a constant and qx qy qx q y
smooth rate of change. Dual-quaternions can use the qˆ x qˆ y   46
qq qq qq
exponential representation similar to quaternions to
generate an interpolation scheme to produce constant
smooth interpolation. Performance Comparison
It can be shown without difficulty that in general a dual-
Shortest or Longest Interpolation Path quaternion takes less operations to compute a general
Contrary to popular belief, a quaternion and dual- transform concatenation compared to a matrix (see Table
quaternion by default will not take the shortest path 1).
between points when interpolated. This is because a
quaternion can represent the same orientation using two Matrix4x4 : 64mult + 48adds
different representations, and consequently a dual- Matrix4x3 : 48mult + 32adds
quaternion. This means that both quaternions and dual- DualQuaternion : 42mult + 38adds
quaternions do not offer a unique representation of an Table 1: Computational cost of combining matrices and
orientation or transformation (i.e., there are two). The dual-quaternions.
difference between the two representation becomes
Furthermore, for rigid skeletal animations, the computation
apparent during interpolation and provide a method for
of world space transforms in addition to the overhead cost
determining the shortest or longest path to be taken during
of transferring the data to the graphics processing unit
interpolation.
(GPU) can be noticeably better. For example, to transfer
The interpolation direction can be calculated by examining the transforms to the GPU each frame a dual-quaternions
the angle between the two transforms. If the angle requires only eight floats compared to a 3x4 matrix that
between the two quaternions (or dual-quaternions) is requires twelve per joint.

Ben Kenwright ([email protected]) (October 2012) pp 8-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

Inverse Kinematics Computer graphics and interactive techniques. ACM


Press, pp. 245–254, 1985.
The conventional method for representing and
[2] M. Schilling, “Universally manipulable body models—
concatenating links together in hierarchical systems is the dual quaternion representations in layered and dynamic
Denavit-Hartenberg [16] matrix convention, and while MMCs,” Autonomous Robots, vol. 30, no. 4, pp. 399–425,
Wang and Ravani [17] proposed an alternative more 2011.
efficient forward recursion method for kinematic [3] B. Kenwright, “A Beginners Guide to Dual-Quaternions:
equations, we propose using dual-quaternions, since they What They Are , How They Work, and How to Use Them
offer an analogous alternative that is numerically stable for 3D Character Hierarchies,” The 20th International
and computationally efficient. Dual-quaternions have Conference on Computer Graphics, Visualization and
shown promising results for providing singularity-free Computer Vision, no. June 26–28, pp. 1–10, 2012.
solutions for inverse kinematic (IK) problems with [4] Q. Ge, A. Varshney, J. P. Menon, and C. F. Chang,
nonlinearities [18]. It is clearly an advantage to use dual- “Double quaternions for motion interpolation,” in
quaternions for rigid hierarchies since each dual- Proceedings of the ASME Design Engineering Technical
quaternion can be concatenated easily, interpolated Conference, 1998.
smoothly and provide rigid transform comparisons [5] S. W. R. Hamilton, “On quaternions; or on a new system
effortlessly. of imaginaries in algebra,” Philosophical Magazine and
Journal of Science, no. July, pp. 10–13, 1844.
Porting to Dual-Quaternion [6] W. Clifford, Mathematical Papers. London, Macmillan,
Converting an exiting matrix scheme to a dual-quaternion 1882.
system is straightforward since much of the operations [7] A. P. Kotelnikov, “Screw calculus and some of its
(i.e., concatenation of transforms) are done the same way. applications in geometry and mechanics,” Kazan (in
For example, the concatenation of transforms with a Russia), 1895.
matrices and dual-quaternions: [8] Leipzig, “Geometrie der Dynamen,” E. Study, 1903.
Matrix [9] I. M. Yaglom, “A simple non-Euclidean geometry and its
physical basis,” Springer Verlag, vol. New York, 1979.
M 03  M 0 M1M 2 M 3 [10] M. L. Keler, “On the theory of screws and the dual
method,” In Proceedings of A Symposium
Dual-Quaternion Commemorating the Legacy, Works, and Life of Sir
Robert Stawell Ball Upon the 100th Anniversary of “A
 03   01 2 3 Treatise on the Theory of Screws,” vol. July 9–11, 2000.
where the subscript represents the transform, while matrix [11] E. Pennestr and R. Stefanelli, “Linear Algebra and
Numerical Algorithms Using Dual,” Multibody System
transform M 0 corresponds the dual-quaternion transform Dynamics, vol. 18, no. 3, pp. 323–344, 2007.
 0 . However, unlike matrices, dual-quaternions provide [12] J. Plùcker, “On a new geometry of space,” Philosophical
an additional repertoire of valuable functions to easily Transactions of the Royal Society of London, vol. 155, no.
compare and interpolate between transforms. 1865, pp. 725–791, 1865.
[13] K. Daniilidis, “Hand-Eye Calibration Using Dual
Conclusion and Final Thoughts Quaternions,” The International Journal of Robotics
This paper has attempted to introduction the reader to the Research, vol. 18, no. 3, pp. 286–298, Mar. 1999.
practical potential of dual-quaternions and their advantages [14] K. Daniilidis and B.-C. Eduardo, “The dual quaternion
in solving kinematic problems (i.e., systems with rotational approach to hand-eye calibration,” Proceedings of the 13th
and translational properties). The fundamental features International Conference on Pattern Recognition, vol. 1,
pp. 318–322, 1996.
and workings of dual-quaternions have been outlined. It
has also been shown, that in general, they provide a [15] L. Kavan, S. Collins, J. Žára, and C. O’Sullivan,
compact and efficient tool for representing rigid “Skinning with dual quaternions,” In 2007 ACM
SIGGRAPH symposium on interactive 3D graphics and
transformation (i.e., simultaneously rotation and games, vol. ACM Press, no. April/May, pp. 39–46, 2007.
translation).
[16] J. Denavit and R. S. Hartenberg, “A Kinematic Notation
In practicality, a dual-quaternion is a tool like any other for Lower-Pair Mechanisms Based on Matrices,” Journal
tool to be used to solve a problem. It is a novel and fresh of Applied Mechanics, vol. 22, no. June, pp. 215–221,
alternative to the de-facto method of matrices with 1955.
numerous benefits that can be integrated into a system with [17] L. T. Wang and B. Ravani, “Recursive computations of
little disruption or complication. It is hoped that the reader kinematic and dynamic equations for mechanical
after reading this paper will go forwards and implement a manipulators,” IEEE Journal of Robotics and Automation,
straightforward dual-quaternion class to enable them to vol. September, no. 3, pp. 124–131, 1985.
explore the potential and decide for themselves if they are [18] Y. Aydın and S. Kucuk, “Quaternion Based Inverse
the right tool for the job. Kinematics for Industrial Robot Manipulators with Euler
Wrist,” IEEE International Conference on Mechatronics,
References vol. July 3–5, pp. 581–586, 2006.
[1] K. Shoemake, “Animating rotation with quaternion
curves,” In Proceedings of the 12th annual conference on

Ben Kenwright ([email protected]) (October 2012) pp 9-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

Appendix
Sample Dual-Quaternion Class Implementation
public class DualQuaternion_c
{
public Quaternion m_real;
public Quaternion m_dual;

public static readonly DualQuaternion_c Identity = new DualQuaternion_c();

public DualQuaternion_c()
{
m_real = new Quaternion(0,0,0,1);
m_dual = new Quaternion(0,0,0,0);
}
public DualQuaternion_c( Quaternion r, Quaternion d )
{
m_real = Quaternion.Normalize( r );
m_dual = d;
}
public DualQuaternion_c( Quaternion r, Vector3 t )
{
m_real = Quaternion.Normalize( r );
m_dual = ( new Quaternion( t, 0 ) * m_real ) * 0.5f;
}
public static float Dot( DualQuaternion_c a, DualQuaternion_c b )
{
return Quaternion.Dot( a.m_real, b.m_real );
}
public static DualQuaternion_c operator* (DualQuaternion_c q, float scale)
{
DualQuaternion_c ret = q;
ret.m_real *= scale;
ret.m_dual *= scale;
return ret;
}
public static DualQuaternion_c Normalize( DualQuaternion_c q )
{
float mag = Quaternion.Dot( q.m_real, q.m_real );
Debug_c.Assert( mag > 0.000001f );
DualQuaternion_c ret = q;
ret.m_real *= 1.0f / mag;
ret.m_dual *= 1.0f / mag;
return ret;
}
public static DualQuaternion_c operator +(DualQuaternion_c lhs, DualQuaternion_c rhs)
{
return new DualQuaternion_c(lhs.m_real + rhs.m_real, lhs.m_dual + rhs.m_dual);
}
// Multiplication order - left to right
public static DualQuaternion_c operator *(DualQuaternion_c lhs, DualQuaternion_c rhs)
{
lhs = DualQuaternion_c.Normalize( lhs );
rhs = DualQuaternion_c.Normalize( rhs );

return new DualQuaternion_c( rhs.m_real * lhs.m_real,


rhs.m_dual * lhs.m_real + rhs.m_real * lhs.m_dual);
}
public static DualQuaternion_c Conjugate( DualQuaternion_c q )
{
return new DualQuaternion_c( Quaternion.Conjugate( q.m_real ),
Quaternion.Conjugate( q.m_dual ) );
}
public static Quaternion GetRotation( DualQuaternion_c q )
{
return q.m_real;
}
public static Vector3 GetTranslation( DualQuaternion_c q )
{
Quaternion t = ( q.m_dual * 2.0f ) * Quaternion.Conjugate( q.m_real );
return new Vector3( t.X, t.Y, t.Z );
}
public static Matrix DualQuaternionToMatrix( DualQuaternion_c q )
{
q = DualQuaternion_c.Normalize( q );

Matrix M = Matrix.Identity;
float w = q.m_real.W;
float x = q.m_real.X;
float y = q.m_real.Y;
float z = q.m_real.Z;

// Extract rotational information


M.M11 = w*w + x*x - y*y - z*z;

Ben Kenwright ([email protected]) (October 2012) pp 10-11


Dual-Quaternions: From Classical Mechanics to Computer Graphics and Beyond

M.M12 = 2*x*y + 2*w*z;


M.M13 = 2*x*z - 2*w*y;

M.M21 = 2*x*y - 2*w*z;


M.M22 = w*w + y*y - x*x - z*z;
M.M23 = 2*y*z + 2*w*x;

M.M31 = 2*x*z + 2*w*y;


M.M32 = 2*y*z - 2*w*x;
M.M33 = w*w + z*z - x*x - y*y;

// Extract translation information


Quaternion t = ( q.m_dual ) * Quaternion.Conjugate( q.m_real ) * 2.0f;
M.M41 = t.X;
M.M42 = t.Y;
M.M43 = t.Z;
return M;
}

public static
DualQuaternion_c ScLERP( DualQuaternion_c from, DualQuaternion_c to, float t )
{
// Shortest path
float dot = Quaternion.Dot(from.m_real, to.m_real);
if ( dot < 0 ) to = to * -1.0f;

// ScLERP = qa(qa^-1 qb)^t


DualQuaternion_c diff = DualQuaternion_c.Conjugate(from) * to;

Vector3 vr = new Vector3(diff.m_real.X, diff.m_real.Y, diff.m_real.Z);


Vector3 vd = new Vector3(diff.m_dual.X, diff.m_dual.Y, diff.m_dual.Z);
float invr = 1 / (float)Math.Sqrt( Vector3.Dot(vr, vr) );

// Screw parameters
float angle = 2 * (float)Math.Acos( diff.m_real.W );
float pitch = -2 * diff.m_dual.W * invr;
Vector3 direction = vr * invr;
Vector3 moment = (vd - direction*pitch*diff.m_real.W*0.5f)*invr;

// Exponential power
angle *= t;
pitch *= t;

// Convert back to dual-quaternion


float sinAngle = Sin(0.5f*angle);
float cosAngle = Cos(0.5f*angle);
Quaternion real = new Quaternion( direction* sinAngle,
cosAngle );
Quaternion dual = new Quaternion( sinAngle*moment+pitch*0.5f* cosAngle *direction,
-pitch*0.5f*sinAngle );

// Complete the multiplication and return the interpolated value


return from * new DualQuaternion_c( real, dual );
}

#if false
public static void SimpleTest()
{
DualQuaternion_c dq0 = new DualQuaternion_c( Quaternion.CreateFromYawPitchRoll(1,2,3),
new Vector3(10,30,90) );
DualQuaternion_c dq1 = new DualQuaternion_c( Quaternion.CreateFromYawPitchRoll(-1,3,2),
new Vector3(30,40,190) );
DualQuaternion_c dq2 = new DualQuaternion_c( Quaternion.CreateFromYawPitchRoll(2,3,1.5f),
new Vector3(5,20,66) );
DualQuaternion_c dq = dq0 * dq1 * dq2;

Matrix dqToMatrix = DualQuaternion_c.DualQuaternionToMatrix( dq );

Matrix m0 = Matrix.CreateFromYawPitchRoll(1,2,3) * Matrix.CreateTranslation(10,30,90);


Matrix m1 = Matrix.CreateFromYawPitchRoll(-1,3,2) * Matrix.CreateTranslation(30,40,190);
Matrix m2 = Matrix.CreateFromYawPitchRoll(2,3,1.5f) * Matrix.CreateTranslation(5,20,66);
Matrix m = m0 * m1 * m2;
}
#endif
} // End DualQuaternion_c

Listing 1: Dual-Quaternion Implementation Class (note, this version of the class was written for clarity a production ready version
could be optimised and made more compact).

Ben Kenwright ([email protected]) (October 2012) pp 11-11

You might also like