<<

Dual for Blending

Ladislav Kavan∗ Steven Collins Carol O’Sullivan Jiri Zara Trinity College Dublin / CTU in Prague Trinity College Dublin Trinity College Dublin CTU in Prague

84.9 FPS 197.4 FPS 55.1 FPS 122 FPS (a) Log-matrix Blending (b) Dual Quaternions (c) Spherical Blend Skinning (d) Dual Quaternions

Figure 1: A comparison of different rigid transformation blending algorithms applied in skinning shows that blending based on dual quater- nions not only eliminates artifacts, but is also much easier to implement and more than twice as fast as previous methods.

Abstract and components independently, such as 4 × 4 homoge- neous matrices, or pairs consisting of a classical and a translation vector. Quaternions have been a popular tool in 3D computer graphics for more than 20 years. However, classical quaternions are restricted We consider the problem of weighted averages, or blending,of to the representation of , whereas in graphical applications 3D rigid transformations. The input consists of n rigid transfor- we typically work with composed with translation (i.e., a mations and n weights w1,...,wn which are convex (i.e., wi ≥ 0, rigid transformation). Dual quaternions represent rigid transforma- and w1 + ...+ wn = 1). The task is to compute a weighted av- tions in the same way as classical quaternions represent rotations. erage of these transformations. A similar problem is transforma- In this paper we show how to generalize established techniques for tion interpolation: the input is also n rigid transformations and n blending of rotations to include all rigid transformations. Algo- key times, but the task is to construct an interpolation curve. Both rithms based on dual quaternions are computationally more effi- problems are equivalent for n = 2, but for n > 2, blending is more cient than previous solutions and have better properties (constant general. This is because any interpolation (e.g., linear, spline) can speed, shortest path and coordinate invariance). For the specific ex- be expressed as a blending with weights considered as functions of ample of skinning, we demonstrate that problems which required time: w1(t),...,wn(t) (see [Buss and Fillmore 2001]). Even though considerable research effort recently are trivial to solve using our transformation interpolation is very important in computer graph- formulation. However, skinning is only one ap- ics, there are many applications where the more general blending is plication of dual quaternions, so several further promising research required instead: e.g., character skinning, blending, spatial directions are suggested in the paper. keyframing and animation compression [Alexa 2002].

CR Categories: I.3.5 [Computer Graphics]: Computational Transformation blending is well studied for 3D rotations. In the Geometry and Object Modeling – Geometric Transformations— case of only two rotations, the established solution is Spherical Lin- [I.3.7]: Computer Graphics—Three-Dimensional Graphics and Re- ear Interpolation (SLERP), introduced by Shoemake [1985]. For alism – Animation cases involving more than two 3D rotations, there are several so- lutions possible, e.g., an iterative solution based on spherical av- erages [Buss and Fillmore 2001], or fast approximate Quaternion Keywords: rigid transformation, dual quaternion, transformation Linear Blending (QLB) [Kavan and Zara 2005] (called Quaternion blending, motion Linear Interpolation (QLERP) in their paper).

For blending of general 3D rigid transformations, there are no proven algorithms described in the literature. In the past, this prob- 1 Introduction lem has typically been solved by ad-hoc algorithms, which work correctly only in the context of a specific application. In this pa- It is well known that classical quaternions are an advantageous rep- per, we show how dual quaternions can be used to generalize the resentation of 3D rotations, in many aspects better than 3 × 3ro- well-established rotation blending algorithms to deal with all rigid tation matrices [Shoemake 1985]. However, rigid objects do not transformations. We present three algorithms: only rotate, but also translate; a rotation composed with translation ScLERP (Screw Linear Interpolation), a generalization of is called a rigid transformation. Any displacement of a rigid ob- SLERP [Shoemake 1985] ject in 3D space can be described by a rigid transformation (known therefore also as a rigid body motion). In this paper, we advocate DLB (Dual quaternion Linear Blending), a generalization of that dual quaternions [Clifford 1882] are in many aspects a better QLB [Kavan and Zara 2005] representation of rigid transformations than those treating rotation DIB (Dual quaternion Iterative Blending), a generalization of ∗e-mail: [email protected] spherical averages [Buss and Fillmore 2001] We prove that all presented algorithms have the same desirable fea- • Constant speed means that the angle of interpolated rotation tures as their rotation-only counterparts. If we employ dual quater- varies linearly with respect to parameter t. nions in applications, we obtain more accurate results and in many cases also faster execution time. Some tasks that have challenged • Shortest path means that the motion between R0 and R1 is a ro- researchers in recent years are trivial to solve using a dual quater- tation about a fixed axis with the smallest angle. nion approach. We demonstrate this for the problem of geometric • skinning, which is an algorithm in common use for real-time ani- Coordinate system invariance requires that it does not matter mation of virtual characters. The implementation of a dual quater- whether a conversion to any other arbitrary coordinate system oc- nion class is very simple, especially when based on existing code curs before or after interpolation. for classical quaternions. We believe that dual quaternions will be- A formal definition of those properties (for general rigid trans- come a standard part of every 3D graphics library, in the same way formations) is provided below. The constant speed, shortest path as the original quaternions are today. and coordinate invariance properties are the reason why SLERP Our Contribution. Previous texts present dual quaternions typ- is superior to other methods. Let us therefore examine those ically in a theoretical, algebraic fashion e.g., [Bottema and Roth properties in detail. The importance of coordinate invariance is 1979]. In Section 3, we introduce the theory of dual quaternions very well-known in geometry and robotics [Murray et al. 1994]. from a practical point of view, emphasizing its application in com- In computer graphics papers concerning transformation blending, puter graphics. Rigid transformation blending based on dual quater- coordinate-invariance is usually not discussed. This is surprising, nions is, to our knowledge, novel. So too is our verification of the because almost all transformation blending algorithms actually are properties of associated algorithms (Section 4 and Appendix A). A coordinate-, see Section 5. We presume this is because the rigorous comparison with different blending algorithms has been concept of coordinates is ingrained in computer graphics, e.g., ev- undertaken (Section 5) and a case study, where our new methods ery application works in some “world-coordinate system”, all mod- are applied to skinning, is also presented (Section 6). eling software displays coordinate axes, etc. The importance of coordinate-invariance in computer animation has been emphasized by Lee and Shin [2002].

The matrix representation of a depends 2 Background and Related Work inherently on the chosen coordinate system. We obtain a different matrix representation for a different choice of coordinate system, even though the transformation is still the same. Ideally, we do not Dual quaternions were developed by Clifford in the nineteenth want the blending method to depend on the representation of the century [Clifford 1882]. They are a special case of the struc- transformation, as we prefer only dependence on the transforma- tures known today as Clifford , which embrace complex tion itself. This is the meaning of coordinate-invariance. A practical , quaternions, dual quaternions, and others [McCarthy argument is that certain algorithms do not work with coordinate- 1990]. Clifford algebras are sometimes called geometric algebras, dependent blending [Ge et al. 1998; Kavan and Zara 2005]. How- whose importance for computer graphics has been discussed re- ever, we do not claim that a coordinate-invariant algorithm is the cently [Hildenbrand et al. 2004]. Very few applications of dual best solution in all situations: for example, if we are just interpolat- quaternions in computer graphics have been described to date: con- ing the position of a teapot (e.g., as in Figure 2) it would be more struction of interpolation curves [Juttler 1994; Ge and Ravani 1994] natural to rotate the teapot around its center of mass, rather than and inverse [Luciano and Banerjee 2000]. This suggests around the screw axis. However, this reasoning assumes that we that dual quaternions are virtually unknown in the computer graph- know beforehand that 1) we are transforming a teapot, and 2) we ics community. This is surprising, because they are quite popular in know its mass distribution (or at least a user-defined approximation other fields, such as robotics [Daniilidis 1999; Perez and McCarthy of its center of mass). Such a priori information may not be avail- 2004]. able in all situations, or it may be too time consuming to compute (e.g., center of mass of a deformable object). A coordinate invariant algorithm is an elegant solution in this case: it works equally for 2.1 Two transformations all coordinate systems, thus it does not matter which one we use. It is interesting to note that coordinate-invariance is also the reason why the weights w1,...,wn of a linear combination of points are re- Before we address the more complex problem of rigid transfor- quired to satisfy the equation w1 + ...+ wn = 1. It would of course mation blending, let us examine first the simple case of n = 2, be possible to compute a linear combination of points with weights where blending is equivalent to interpolation. Let M0 and M1 not summing to one, but the result would be dependent on the co- be two rigid transformations (represented by 4 × 4 homogeneous ordinate system with respect to which the points are expressed. matrices), and t ∈ [0,1] the interpolation parameter. Any inter- polation of two rigid transformations, denoted as Φ(t,M0,M1),is Constant speed and shortest path properties are more intuitive: they considered valid if it satisfies the following basic requirements: correspond to the motion with the smallest amount of work (any ac- Φ(0,M0,M1)=M0, Φ(1,M0,M1)=M1 and Φ(t,M0,M1) is a celeration or motion of the rotation axis implies additional energy). rigid transformation for all t ∈ [0,1]. Moreover, the interpolation This is why the blending looks natural: if we were to perform the should be independent of the order of input transformations, i.e., motion ourselves, we would also tend to avoid unnecessary work. Φ(t,M0,M1)=Φ(1 − t,M1,M0). However, even when taking all these requirements into account, there are still an infinite Formal definition of interpolation properties. Let Φ(t,M0,M1) of ways to define a valid interpolation. It is thus desirable to pick denote a valid interpolation between rigid transformations M0 an interpolation method which satisfies the most advantageous ad- and M1 with parameter t ∈ [0,1]. The rigid transformation −1Φ( , , ) α( ) ditional properties. M0 t M0 M1 can be decomposed to angle of rotation t , axis of rotation a(t), amount of translation δ(t) and unit translation For the case of two 3D rotations R0,R1, the popular Spherical Lin- direction d(t). The interpolation is called ear Interpolation (SLERP) algorithm [Shoemake 1985] has the fol- lowing properties: • Constant speed if the derivative of both α(t) and δ(t) is constant. • Shortest path if a(t) and d(t) are constant, and α(1) ∈ [−π,π]. shortest path and constant speed. However, for the case of rigid transformations, we find our proposed algorithms based on dual • Coordinate system invariant if, for an arbitrary rigid transforma- quaternions to be much more practical (in terms of both robust- Φ( , , ) −1 = Φ( , −1, −1) tion T,istruethatT t M0 M1 T t TM0T TM1T . ness and computational speed). A compact representation of a rigid logarithm is a twist [Bregler and Malik 1998] or hexanion [Angelidis 2004]. Blending of those entities is equiva- 2.2 Multiple transformations lent to Alexa’s method.

A limitation of SLERP is that it cannot be directly generalized for Conventions. We denote scalars by lower-case letters, vectors and the blending of more than two rotations. For example, the obvi- quaternions by bold and matrices by capital letters. Dual quantities ous generalization to three rotations R0,R1,R2 is to first compute are distinguished from non-dual by a caret, for example,a ˆ denotes a SLERP of R0 with R1 and then interpolate the result with R2.This and qˆ a dual quaternion. The i-th component of vector solution has a serious drawback, which is the dependence on the v is written as vi, thus also v =(v1,...,vn). The of vec- , , order of rotations: if we reorder the rotations e.g., to R2 R1 R0 tors v and w is denoted as v,w and the norm v is a shortcut for (and change the blending weights accordingly), we obtain a dif- v,v. Cross product is denoted as v × w. For better readability, ferent result. A better generalization of SLERP, independent of the we denote the exponential mapping as exp(x), instead of ex. order of rotations, has been described in [Buss and Fillmore 2001]. A similar algorithm has been also discussed by Johnson [2003]. However, both of the above algorithms are iterative and slower than the closed-form SLERP. For applications in real-time graphics, a 3 Dual Quaternions fast closed-form approximation has been advocated [Kavan and Zara 2005]. It works by using a simple linear combination of unit quaternions followed by projection onto a unit hypersphere. These This section provides a brief introduction to dual numbers and dual methods are however limited only to rotations. For the case of gen- quaternions. We focus only on the main ideas, omitting some eral rigid transformations, the following algorithms have been used lengthy mathematical proofs, which can typically be done by direct in the past: computation. For a more detailed introduction, see [Bottema and Roth 1979; McCarthy 1990]. We assume the reader is already fa- miliar with ordinary quaternions, otherwise see for example [Dam • Linear blending of matrices. The component-wise linear et al. 1998; Eberly 2001]. Dual quaternions can be considered as blending of rigid transformation matrices is the most straightfor- quaternions whose elements are dual numbers. The of dual ward solution. The problem with this method is that its result is numbers is similar to complex numbers: any dual numbera ˆ can often not a rigid transformation matrix. The blended matrix can be written asa ˆ = a + εaε ,wherea is the non-dual part, aε the even be singular (projecting 3D objects to 2D). 0 0 dual part and ε is a dual unit satisfying ε2 = 0. The dual conju- = − ε • Decomposition to rotation and translation. An obvious solu- gate is analogous to the : aˆ a0 aε . Multi- ( + ε )( + ε )= tion to the problems of linear blending of matrices is to decompose plication of two dual numbers is given as a0 aε b0 bε −1 the rigid transformation matrix into a rotation and translation com- a0b0 + ε(a0bε + aε b0). The inverse of a dual numbera ˆ is given ponent. The translation part can be blended linearly without any 1 = 1 −ε aε by a +εaε a 2 , as can be immediately verified. The previous 0 0 a0 difficulties, and the rotation part can be converted to a quaternion expression is defined only when a = 0. Purely dual numbers, that and blended properly using [Buss and Fillmore 2001]. However, 0 is dual numbers with a0 = 0, do not have an inverse. This is a funda- there is an associated hidden drawback: the decomposition to ro- mental difference from complex numbers, because every non-zero tation and translation inevitably depends on the coordinate system, has an inverse. The root is defined only for thus we lose the convenient property of coordinate independence. √dual numbers√ with a positive non-dual part, and it is computed as If this is to work reasonably, we must provide a suitable coordinate √aε a0 + εaε = a0 + ε . system in which the decomposition will be performed. 2 a0 = + + + The construction of a such a coordinate system has been presented A dual quaternion qˆ can be written as qˆ wˆ ixˆ jyˆ kzˆ,where ( , , ) in [Kavan and Zara 2005]. Unfortunately, the proposed compu- wˆ is the scalar part (dual number), xˆ yˆ zˆ is the vector part (dual , , tation of a coordinate system is based on a least squares optimiza- vector), and i j k are the usual quaternion units. The dual unit ε ε = ε tion, solved by the Singular Value Decomposition (SVD) algorithm. commutes with quaternion units, for example i i. A dual This is restrictive, because SVD is a complex and slow algorithm, quaternion can be also considered as an 8-tuple of real numbers, or = +ε unsuitable for real-time applications. Moreover, the computation as the sum of two ordinary quaternions, qˆ q0 qε . Conjugation of the auxiliary coordinate system does not depend on the blend- of a dual quaternion is defined using classical quaternion conjuga- ∗ = ∗ + ε ∗ ing weights – it is thus doubtful whether this can really be consid- tion: qˆ √q0 q√ε The norm of a dual quaternion can be written ∗ ∗ ered as a correct blending. Note that no such problems occur with as qˆ = qˆ qˆ = qˆqˆ , which expands to coordinate-invariant blending. q ,qε  • qˆ = qˆ ∗qˆ = q + ε 0 Blending of matrix logarithms. The advantage of the trans- 0 q  formation blending algorithm based on matrix logarithms [Alexa 0 2002] is that it works with more general transformations (not just The norm satisfies the usual property pˆqˆ = pˆqˆ.Theinverse rigid). However, the manner in which it blends rotations has of a dual quaternion is defined only when q0 = 0. In this case, opened an interesting discussion. An on-line critique of Alexa’s ∗ −1 = qˆ article [Bloom et al. 2004] was presented, which points out that we have qˆ qˆ 2 . Unit dual quaternions are those satisfying Alexa’s blending applied for rotations is not shortest path, i.e., it qˆ = 1. According to the previous formula, a dual quaternion qˆ can produce a longer trajectory than necessary. However, Bloom is unit if and only if q0 = 1andq0,qε  = 0. Note that unit et al. do not propose any alternative solution for the case of gen- dual quaternions are always invertible (their inverse is just conjuga- eral transformations. In this paper, we show how Alexa’s original tion). We denote the set of unit dual quaternions as Qˆ1. Geometri- algorithm for general transformations can be upgraded to be both cally, Qˆ1 is a manifold in 8-dimensional (called an image-space of dual quaternions [McCarthy 1990]). Just like ordi- Every unit dual quaternion qˆ can be written as nary quaternions, dual quaternions are also associative, distributive, but not commutative. θˆ θˆ qˆ = cos + sˆ sin (2) As expected, unit dual quaternions naturally represent 3D rotation, 2 2 when the dual part qε = 0.Ifwehavea3Dvector(v0,v1,v2),we = + ε( + + define the associated unit dual quaternion as vˆ 1 v0i v1 j where sˆ is a unit dual vector with zero scalar part, see [McCarthy ) ( , , ) v2k . The rotation of vector v0 v1 v2 by a dual quaternion qˆ then 1990] or [Daniilidis 1999]. Note that this looks like the formula for ˆ ˆ ∗ ˆ ∗ can be written as qvˆq (where q denotes both quaternion and dual ordinary quaternions, just employing the dual angle θˆ = θ0 + εθε conjugation). This is obvious, because if qε = 0 then qˆ = q0 and = + ε ε ∗ and unit dual vector sˆ s0 s . The geometric interpretation of qˆvˆqˆ simplifies to those quantities is related to screw motion, that is a rotation and ∗ ∗ translation about the same axis. Chasle’s theorem [Daniilidis 1999] q (1+ ε(v i + v j + v k))q = 1+ εq (v i + v j + v k)q 0 0 1 2 0 0 0 1 2 0 states that any rigid transformation can be described by a screw ( + + ) ∗ motion, see Figure 2. Angle θ /2 is the angle of rotation, and unit where q0 v0i v1 j v2k q0 is the familiar formula for rotation by 0 an ordinary quaternion. vector s0 represents the direction of the axis of rotation. θε /2is the amount of translation along vector s0,andsε is the moment of the axis. Moment is an unambiguous description of the position of an axis in space. It is given by equation sε = p × s0,wherep is a vector pointing from the origin to an arbitrary point on the axis. Which point we choose is not important, because for any other point of the axis, say p + cs0 (where c is an arbitrary scalar), we obtain (q /2).s e 0 the same moment: (p + cs0) × s0 = p × s0. This gives us another insight: whereas classical quaternions can represent only rotations whose axes pass through the origin, dual quaternions can represent rotations with arbitrary axes. q /2 0 s 0 Using Taylor series, we can derive Euler’s identity for dual quater- s ( θˆ )= θˆ + θˆ 0 p nions: exp sˆ 2 cos 2 sˆ sin 2 .Ifqˆ is as in Formula (2), then its ( )= θˆ logarithm is given as log qˆ sˆ 2 . A power of dual quaternion qˆ 0 p 0 uˆ = ( )= ( θˆ )+ ( θˆ ) is then defined naturally: qˆ exp uˆlogqˆ cos uˆ 2 sˆ sin uˆ 2 . We see that the dual quaternion formulas are very similar to corre- Figure 2: Example of a screw motion, side and top view. Each rigid sponding formulas for ordinary quaternions [Dam et al. 1998]. transformation can be described as a screw: rotation about an axis Dual quaternions exhibit the so called antipodal property of classi- by angle θ0/2 and translation with magnitude θε /2 along the same cal quaternions, i.e., the fact that both qˆ and −qˆ represent the same axis. The axis, with direction determined by unit vector s0, needs not pass through the origin 0. Its position in space is given by vector rigid transformation. The mapping between rigid transformations p pointing from the origin to some point on the axis. The choice of and unit dual quaternions is thus one to two. Even though both q0 − t (− )t vector p is not unique, thus dual quaternions work with the unique and q0 represent the same rotation, the powers q0 and q0 are different: one corresponds to clockwise and the second to coun- moment: p × s0. terclockwise rotation, see Figure 3. During matrix to quaternion − What is interesting is that dual quaternions can also represent 3D conversion, we can choose between q0 and q0. In the following, translation. A unit dual quaternion tˆ,definedastˆ = 1 + ε (t i + we assume that the signs corresponding to the shortest trajectory 2 0 were chosen. In general, this can be done as described in [Park t1 j + t2k) corresponds to translation by vector (t0,t1,t2) (note that dual quaternions work with half of the translation vector, in analogy et al. 2002]. In practice, a trivial method is usually possible [Kavan to classical quaternions, which work with half of the angle of rota- and Zara 2005]. ∗ tion). If we simplify tˆvˆtˆ , we obtain 1 + ε((v0 +t0)i +(v1 +t1) j + (v2 +t2)k), which shows that the unit dual quaternion tˆ really per- forms translation by (t0,t1,t2). Rigid transformation is a composi- tion of rotation and translation, and composition of transformations q t corresponds to multiplication of dual quaternions. If the rotation 0 ,0

The bi-invariance of DIB (and thus also the coordinate-invariance), Lin. Dec. Log. ScLERP DLB DIB follows from the bi-invariance of DLB and Lemma 1 in the Ap- Rigidity - + + + + + pendix A. The comparison of ScLERP with DIB is quite surpris- Bi-inv. + - - + + + ing. Not only is the result of DIB exactly equivalent to the result Coord-inv. + - + + + + of ScLERP, but DIB finds this solution in just a single iteration (the n > 2 + + + - + + second pass through the loop finds that xˆ is zero and performs Const-spd. - + - + - + no update of bˆ). We prove this interesting property in Lemma 3 in Shortest - + - + + + the Appendix A. An immediate consequence is that DIB is also con- FLOPS 23n N/A 160+ 240 65+ N/A stant speed and shortest path. The DIB algorithm therefore presents 104n 49n an exact rigid transformation blending, but it can be slower to com- pute than the closed-form DLB. Table 1: Properties of different rigid transformation blending al- gorithms (top to bottom): preserving of rigid transformations, bi- invariance, coordinate-invariance, support of more than two rigid transformations, constant speed, shortest path, and number of 5 Comparison with Other Methods FLOPS for blending n rigid transformations. FLOPS for Dec. and DIB depend on the actual input and on desired precision, because the algorithms are iterative. Besides the DLB and DIB algorithms described in the previous sec- tion, several alternative methods for blending of rigid transforma- tions have been described. This section compares the properties We conclude that, for two rigid transformations, the optimal choice of these blending algorithms in terms of coordinate-invariance (bi- is ScLERP. If we need a precise solution for more than two trans- invariance), constant speed, shortest path, and computation time in formations, we have to employ the iterative DIB. The FLOPS of terms of FLOPS. Those properties for dual quaternion based algo- log-matrix blending reported in Table 1 refer to an optimization, rithms were discussed in Section 4. Properties of previous rigid which is restricted to rigid transformations and employs a closed- transformation blending algorithms are discussed below and sum- form Rodrigues formula for rigid transformations [Murray et al. marized in Table 1. 1994; Angelidis 2004]. However, even though it is closed-form, the Rodrigues formula is still more difficult to compute than the simple Linear combination of matrices (Lin). Because of the distribu- dual quaternion exp and log. We see that there is no reason to ap- tivity of matrix products, this method is naturally bi-invariant (and ply log-matrix blending for rigid transformations, because DLB has thus also coordinate invariant). Constant speed and shortest path better properties and faster runtime. In the calculation of FLOPS, properties do not hold, because their definition assumes that the we assume that both input and output are 4 × 4 homogeneous ma- trices (specifically, the FLOPS for matrix↔dual quaternion con- on a CPU, because no GPU implementation was available for these versions are included in Table 1; if an application works internally methods. The piece of cloth shown in Figure 1 has 6000 vertices, with quaternions instead of matrices, then the performance of our 12000 triangles and 49 joints (observe the discontinuity of spheri- proposed algorithms is even better). cal blending in Figure 1(c)). The measurements, together with the visual results in Figures 1 and 6, clearly show that dual quaternion blending is not only more accurate, but also more than twice as fast as both log-matrix and spherical blending. Dual quaternion 6 Case Study: Skinning skinning is slightly slower than linear blend skinning, but has the advantage of artifact elimination (Figure 6(a-b)) and usage of fewer Blending of rigid transformations has many applications in com- registers – dual quaternions only need 8 floats instead of the 12 puter graphics, as shown already by Alexa [2002]. One particular required by matrices, which is of particular benefit for the GPU im- application, geometric skinning, has received a lot of research at- plementation. tention recently, so we have chosen this problem to demonstrate 12 0.8 the behavior of dual quaternion algorithms in practice. In geomet- 11.78 ric skinning, a rigged virtual model (such as a character, animal or 10.83 0.6 0.65 piece of cloth) is composed of a triangular mesh, a list L of rigid 8 0.52 transformations, and weights for every vertex in the mesh. Tradi- 0.4 tionally, the list L is interpreted as a list of joint displacements from 4 5.07 the reference to the animated skeleton. However, geometric skin- 3.67 0.2 ning can be applied also for general deformable models without any LBS Log SBS DLB LBS DLB skeleton, as has been shown recently [James and Twigg 2005]. The 0 0.0 animation of the whole model is driven by the animation of indi- Pentium 4 / 3.4 GHz GeForce 6600 GT vidual transformations in L. The task of the skinning algorithm is to plausibly deform the skin for a given set of transformations. An Figure 5: Average CPU/GPU runtimes for skin deformation of a arbitrary vertex v in the mesh is displaced as follows: let us suppose woman model in milliseconds. there are m transformations, C1,...,Cm from L, influencing vertex v, and the convex weights of vertex v are w1,...,wm. A geomet- ric skinning algorithm then computes B, the blended rigid trans- (a) (b) formation of C1,...,Cm with weights w1,...,wm.Thefinalvertex position in the deformed skin is computed simply as Bv.Thisde- formation method is very popular for its simplicity and speed. Note however, that if additional information is available, such as mea- surements of real subjects, better methods exist [Allen et al. 2002; Sand et al. 2003]. A number of approaches to geometric skinning have been recently presented, each one employing a different method of rigid trans- formation blending. Mohr and Gleicher [2003] apply Linear Blend Skinning (LBS), which uses an efficient linear combination of ma- trices, but exhibits anomalies such as the candy wrapper artifact (c) (d) (see Figure 6(a)). Better visual results can be achieved, but at the cost of using auxiliary joints and example skins. Hejl [2004] ig- nores blending of translation and performs linear quaternion blend- ing for rotations. This works correctly only if the influencing trans- formations C1,...,Cm ofeveryvertexhaveacommonfixedpoint, which is true only in simplified skeletal models, but not in general. Magnenat-Thalmann et al. [2004] apply Alexa’s [2002] log-matrix blending to character skinning and cloth simulation. The problems of Alexa’s algorithm discussed above manifest in non-natural skin deformations for certain skeletal postures (see Figure 1(a) and Fig- Figure 6: (a) Typical “candy wrapper” of linear blending, (b) solved ure 6(c)). Kavan and Zara’s Spherical Blend Skinning (SBS) [2005] ( , ) by dual quaternion blending. (c) Non-shortest path of log-matrix blends quaternion translation pairs and copes with the depen- blending implies non-natural deformations, (d) shortest-path dual dence on the coordinate system by computing the optimal origin quaternion blending. of the coordinate system (called rotation center). Unfortunately, the optimization involves a complex and slow SVD (Singular Value Decomposition) algorithm. To make real-time execution possible, SVD is computed only for clusters of vertices. However, this in- 7 Conclusions and Future Work troduces discontinuities in the deformed skin between individual clusters (see Figure 1(c)). As we see, no single previous methods is clearly superior – each presents trade-offs that must be considered. Rigid transformation blending algorithms based on dual quater- nions exhibit more advantageous properties, and faster execution We have applied our DLB algorithm to the problem of geometric times than previous methods. We verified this both theoretically skinning and have developed both CPU and GPU implementations. and on a practical case study of skinning. We believe that dual For our experiments, we used a skeletal model of a woman with quaternion skinning is the algorithm that will finally replace linear 5002 vertices, 9253 triangles, and 54 joints. The average runtime blend skinning in computer games. In the future, the dual quater- performance is reported in Figure 5. We compared the speed with nion blending algorithms presented in this paper could be applied log-matrix blending (Log) and spherical blend skinning (SBS) only for example in: • motion blending – extension of [Park et al. 2002] GE,Q.J.,VARSHNEY,A.,MENON,J.,AND CHANG, C. 1998. • Double quaternion for motion interpolation. In Proc. 1998 motion analysis & compression – as suggested by [Alexa 2002] ASME Design Manufacturing Conference. • spatial keyframing – extension of [Igarashi et al. 2005] GOVINDU, V. M. 2004. Lie-algebraic averaging for globally con- • computer vision – averaging of measured position and orienta- sistent motion estimation. In CVPR (1), 684–691. tion of a rigid object HEJL, J., 2004. Hardware skinning with quaternions. Game Pro- • graphics hardware – dual quaternions take 8 scalars to represent gramming Gems 4, Charles River Media, 487–495. a rigid transformation instead of the 12 required for a matrix. HILDENBRAND,D.,FONTIJNE,D.,PERWASS,C.,AND DORST, L., 2004. and its application to computer To conclude, one of the biggest advantages of dual quaternions is graphics. EG 2004 tutorial #3. that they are based on classical quaternions, which are well-known in the computer graphics community. We believe that dual quater- IGARASHI,T.,MOSCOVICH,T.,AND HUGHES, J. F. 2005. Spa- nions will soon become part of every 3D graphics library. tial keyframing for performance-driven animation. In SCA ’05: Proceedings of the 2005 ACM SIGGRAPH/Eurographics sympo- sium on Computer animation, ACM Press, New York, NY, USA, References 107–115. JAMES,D.L.,AND TWIGG, C. D. 2005. Skinning mesh anima- tions. ACM Trans. Graph. 24, 3, 399–407. ALEXA, M. 2002. Linear combination of transformations. In SIGGRAPH ’02: Proceedings of the 29th annual conference JOHNSON, M. P. 2003. Exploiting Quaternions to Support Expres- on Computer graphics and interactive techniques, ACM Press, sive Interactive Character Motion. PhD thesis, MIT. 380–387. JUTTLER, B. 1994. Visualization of moving objects using dual ALLEN,B.,CURLESS,B.,AND POPOVIC, Z. 2002. Articulated quaternion curves. Computers & Graphics 18, 3, 315–326. body deformation from range scan data. In SIGGRAPH ’02: Proceedings of the 29th annual conference on Computer graph- KAVA N ,L.,AND ZARA, J. 2005. Spherical blend skinning: A ics and interactive techniques, ACM Press, New York, NY,USA, real-time deformation of articulated models. In 2005 ACM SIG- 612–619. GRAPH Symposium on Interactive 3D Graphics and Games, ACM Press, 9–16. ANGELIDIS, A., 2004. Hexanions: 6D space for twists. Technical report OUCS-2004-20, University of Otago. LEE,J.,AND SHIN, S. Y. 2002. General construction of time- domain filters for orientation data. IEEE Transactions on Visu- BLOOM,C.,BLOW,J.,AND MURATORI, C., 2004. Errors alization and Computer Graphics 8, 2, 119–128. and omissions in Marc Alexa’s Linear combination of trans- formations. http://www.cbloom.com/3d/techdocs/lcot_ LUCIANO,C.,AND BANERJEE, P. 2000. Avatar kinematics mod- errors.pdf. eling for telecollaborative virtual environments. In WSC ’00: Proceedings of the 32nd conference on Winter simulation,So- BOTTEMA,O.,AND ROTH, B. 1979. Theoretical kinematics. ciety for Computer Simulation International, San Diego, CA, North-Holland Publishing Company, Amsterdam, New York, USA, 1533–1538. Oxford. MAGNENAT-THALMANN,N.,CORDIER,F.,SEO,H.,AND PA- BREGLER,C.,AND MALIK, J. 1998. Tracking people with twists PAGIANAKIS, G. 2004. Modeling of bodies and clothes for and exponential maps. In CVPR ’98: Proceedings of the IEEE virtual environments. In CW ’04: Proceedings of the 2004 Inter- Computer Society Conference on Computer Vision and Pattern national Conference on Cyberworlds (CW’04), IEEE Computer Recognition, IEEE Computer Society, Washington, DC, USA, 8. Society, 201–208. BUSS,S.R.,AND FILLMORE, J. P. 2001. Spherical averages and MCCARTHY, J. M. 1990. Introduction to theoretical kinematics. applications to spherical splines and interpolation. ACM Trans. MIT Press, Cambridge, MA, USA. Graph. 20, 2, 95–126. MOAKHER, M. 2002. Means and averaging in the of rota- CHAR,B.,GEDDES,K.,AND GONNET, G. 1983. The Maple tions. SIAM Journal on Matrix Analysis and Applications 24,1, symbolic computation system. j-SIGSAM 17, 3–4 (Aug./Nov.), 1–16. 31–42. MOHR,A.,AND GLEICHER, M. 2003. Building efficient, accurate CLIFFORD, W. 1882. Mathematical Papers. London, Macmillan. character skins from examples. ACM Trans. Graph. 22, 3, 562– DAM,E.,KOCH,M.,AND LILLHOLM, M., 1998. Quaternions, 568. interpolation and animation. Technical Report DIKU-TR-98/5, MURRAY,R.M.,SASTRY,S.S.,AND ZEXIANG, L. 1994. A University of Copenhagen. Mathematical Introduction to Robotic Manipulation. CRC Press, DANIILIDIS, K. 1999. Hand-eye calibration using dual quater- Inc., Boca Raton, FL, USA, 413–414. nions. International Journal of Robotics Research 18, 286–298. PARK,S.I.,SHIN,H.J.,AND SHIN, S. Y. 2002. On-line locomo- EBERLY, D. 2001. 3D game engine design: a practical approach tion generation based on motion blending. In Proceedings of the to real-time computer graphics. Morgan Kaufmann Publishers 2002 ACM SIGGRAPH/Eurographics symposium on Computer Inc. animation, ACM Press, 105–111.

GE,Q.J.,AND RAVANI, B. 1994. Computer aided geometric de- PEREZ,A.,AND MCCARTHY, J. M. 2004. Dual quaternion syn- sign of motion interpolants. ASME Journal of Mechanical De- thesis of constrained robotic systems. Journal of Mechanical sign 116, 3, 756–762. Design 126, 425–435. ∗ − ∗ ∗ ∗ + − SAND,P.,MCMILLAN,L.,AND POPOVIC, J. 2003. Continuous t log((pˆ qˆ)1 uˆ)) = (pˆ qˆ)uˆ exp((t − uˆ)log(pˆ qˆ)) = (pˆ qˆ)uˆ t uˆ = capture of skin deformation. ACM Trans. Graph. 22, 3, 578–586. (pˆ ∗qˆ)t = ScLERP(t;1,pˆ ∗qˆ). In the following iteration, the DIB algorithm computes xˆ =(1 − t)logbˆ ∗ + t log(bˆ ∗pˆ ∗qˆ)=(1 − SHOEMAKE, K. 1985. Animating rotation with quaternion curves. 1 1 ) (( ∗ )−t )+ (( ∗ )1−t )=(2 − + − 2) ( ∗ )= In Proceedings of the 12th annual conference on Computer t log pˆ qˆ t log pˆ qˆ t t t t log pˆ qˆ 0 and thus the algorithm DIB(t;1,pˆ ∗qˆ) terminates with zero error graphics and interactive techniques, ACM Press, 245–254. ∗ and returns bˆ 1 exp(0)=bˆ 1 = ScLERP(t;1,pˆ qˆ). Multiplication from left by pˆ and using the left-invariance yields DIB(t;pˆ,qˆ)= ( , ) Appendix A ScLERP t;pˆ qˆ .

= θˆ + θˆ , Lemma 1. Let qˆ cos 2 sˆ sin 2 ,whereqˆ sˆ are unit dual quater- Appendix B nions, and sˆ has zero scalar part. Then for any unit dual quaternion mˆ , both of the following equations are true: In this appendix, we prove the non-constant speed of log-matrix θˆ ∗ θˆ ∗ ∗ ∗ blending [Alexa 2002]. This problem has an interesting history. 1) exp(mˆ sˆ mˆ )=mˆ exp(sˆ )mˆ , 2) log(mˆ qˆmˆ )=mˆ log(qˆ)mˆ The author of log-matrix blending claims, without proof, that his 2 2 method is not constant speed [Alexa 2002]. Subsequently, a critique Proof. Since the scalar part of sˆ is zero, the same is true for the of log-matrix blending is posted on-line [Bloom et al. 2004], which θˆ ∗ points out mistakes in Alexa’s paper [Alexa 2002]. Among many scalar part of mˆ sˆ 2 mˆ , as can be shown by direct computation (we good insights, it unfortunately mentions also the fact that log-matrix employed Maple [Char et al. 1983]). This means that the exp on the blending actually is constant speed. This is not true, as we prove ) left hand side of 1 is well defined and, according to its definition, below.

θˆ ∗ θˆ θˆ ∗ θˆ θˆ ∗ exp(mˆ sˆ mˆ )=cos + mˆ sˆ sin mˆ = mˆ (cos + sˆ sin )mˆ 2 2 2 2 2 Background on Log-matrix Blending because a dual number always commutes with a dual quaternion and mˆ mˆ ∗ = 1. This shows the first equation. The proves of the Before we start with the actual proof, we review log-matrix blend- second one is similar: ing with a special focus on rotation blending. This gives us a deeper insight into the problem. ∗ θˆ θˆ ∗ θˆ ∗ θˆ mˆ qˆmˆ = mˆ (cos + sˆ sin )mˆ = cos + mˆ sˆmˆ sin × 2 2 2 2 Let us consider a simple situation of two 3 3 rotation matrices R0 and R1.LetRt be a blending (interpolation) between those two ma- ˆ = = (mˆ qˆmˆ ∗)=mˆ sˆ θ mˆ ∗ = mˆ (qˆ)mˆ ∗ trices, i.e., a matrix which for t 0 becomes R0,fort 1 becomes Therefore log 2 log ,aswewantedto ∈ ( , ) prove. R1 and for t 0 1 is a valid rotation matrix. What we informally referred as speed in the above, is actually an of Lemma 2. ScLERP is bi-invariant, that is for any unit dual quater- Rt. The formula expressing angular velocity in the body (moving) nions rˆ,pˆ,qˆ and any interpolation parameter t ∈ [0,1], both of the coordinate system is following equations are true: − ∂R M(ω )=R 1 t (3) ScLERP(t;rˆpˆ,rˆqˆ)=rˆScLERP(t;pˆ,qˆ) t t ∂t ScLERP(t;pˆrˆ,qˆrˆ)=ScLERP(t;pˆ,qˆ)rˆ see [Murray et al. 1994]. Alternatively, we could also use a simi- ( , )= lar formula for angular velocity expressed in the spatial coordinate Proof. The left invariance is easy, because ScLERP t;rˆpˆ rˆqˆ system. This angular velocity differs only by the reference coor- rˆpˆ(pˆ ∗rˆ∗rˆqˆ)t = rˆpˆ(pˆ ∗qˆ)t = rˆScLERP(t;pˆ,qˆ). Proving the right in- ( , )= ( ∗ ∗ )t dinate system, and thus its magnitude (which we aim to compute) variance is a little more tricky: ScLERP t;pˆrˆ qˆrˆ pˆrˆ rˆ pˆ qˆrˆ . is the same. In our analysis, we will work with the body angular It is now sufficient to show that (rˆ∗pˆ ∗qˆrˆ)t = rˆ∗(pˆ ∗qˆ)trˆ, because this ∗ ∗ t ∗ ∗ t velocity, although we could equally well work with the spatial an- gives us pˆrˆ(rˆ pˆ qˆrˆ) = pˆrˆrˆ (pˆ qˆ) rˆ = ScLERP(t;pˆ,qˆ)rˆ.How- ( ) ( ∗ ∗ )t = ( ( ∗ ∗ )) gular velocity. In Formula (3), M a is a function mapping vector ever, the power can be written as rˆ pˆ qˆrˆ exp t log rˆ pˆ qˆrˆ . a =(a ,a ,a ) to an anti-symmetric matrix Thanks to Lemma 1, we can derive that exp(t log(rˆ∗pˆ ∗qˆrˆ)) = 1 2 3 exp(trˆ∗ log(pˆ ∗qˆ)rˆ)=rˆ∗ exp(t log(pˆ ∗qˆ))rˆ = rˆ∗(pˆ ∗qˆ)t rˆ. ⎛ ⎞ 0 −a a ⎝ 3 2 ⎠ Lemma 3. For the case of two rotations, the DIB(t;pˆ,qˆ) algorithm M(a)= a3 0 −a1 (4) converges in a single iteration with result ScLERP(t;pˆ,qˆ). −a2 a1 0

Proof. Thanks to the bi-invariance of DIB, we can perform the The multiplication of any vector x =(x1,x2,x3) by this matrix cor- same simplification as when comparing DLB with ScLERP, that is responds to the cross product, i.e., M(a)x = a × x. Therefore, the ∗ instead of DIB(t;pˆ,qˆ) and ScLERP(t;pˆ,qˆ), compare DIB(t;1,pˆ qˆ) vector ωt in Formula (3) is the common vector representation of an- ∗ ( ) and ScLERP(t;1,pˆ qˆ). Let us denote the initial value of bˆ as gular velocity. The anti-symmetric matrix M a is connected with /  bˆ = DLB(t;1,pˆ ∗qˆ). With weight vector w =(1 − t,t) as the matrix logarithms. If R is a rotation about axis a a with angle 0 a, then its logarithm logR = M(a). This gives us an intuitive bˆ = bˆ (( − input, the DIB computes in the first iteration 1 0 exp 1 explanation of the rotation matrix logarithm. To verify this fact, ) (ˆ ∗)+ (ˆ ∗ ∗ )) t log b0 t log b0pˆ qˆ . As shown in Section 4, the only dif- consider a differential equation describing rotation of a point p at ference between DLB and ScLERP is in the angle of rotation and ∗ uˆ time t with angular velocity a: amount of translation. It means that bˆ 0 =(pˆ qˆ) for some dual numberu ˆ. Since for unit dual quaternions conjugation is the same ∂p(t) as inverse, we can write bˆ =(pˆ ∗qˆ)uˆ exp((1 − t)log((pˆ ∗qˆ)−uˆ)+ = a× p(t)=M(a)p(t) 1 ∂t The solution of this differential equation can be expressed using the extract the angular velocity vector according to Formula (4), we matrix exponential obtain vector ωt =(ωt,0,ωt,1,ωt,2),where √ √ ( )= ( ( ) ) ( ) p t exp M a t p 0 (5) −t2 − 1+ 1+t2 sin( 1+t2) t ωt,0 = − where p(0) is the initial condition, i.e., the position of the point at 1+t2 2 time 0. We can observe that the term exp(M(a)t) in Formula (5) √ √ 4 + 2 + + 2 ( + 2) a/a t t 1 t sin 1 t is nothing but the matrix of rotation about axis with angle ωt,1 = ta. Therefore, the matrix R describing rotation about axis a/a 1+t2 2 with angle a can be written as R = exp(M(a)).Fromthis,it √ = ( ) cos( 1+t2) − 1 immediately follows that logR M a ,aswewantedtoshow. ω , = t 2 1+t2 In the following, Rt will denote the result of log-matrix blending, given according to [Alexa 2002] as After computing the magnitude of vector ωt we get √ R = exp((1−t)logR +t logR ) (6) 4 2 2 t 0 1 t +t − 2cos( 1+t )+2 ωt  = + 2 2 where exp and log denote the matrix exponential and logarithm. 1 t The geometrical interpretation of matrix logarithm gives us an in- sight into what the log-matrix blending (limited to rotations) actu- Obviously, this function is not constant for t ∈ [0,1], see also its ally does: linear blending of the axis-angle representation of rota- graph in Figure 7. tions. w 0.962 Log-Matrix Blending in Maple 0.960

To show that log-matrix blending is not constant speed, it is suffi- 0.958 cient to find two rotation matrices R0, R1, and show that the mag- ω  nitude of angular velocity of their blend Rt , i.e., t according 0.956 t to Formula (3), is not a constant function. Let us define R0 as a 0 0.2 0.4 0.6 0.8 1.0 rotation about axis (1,0,√0) with√ angle 1 radian, and√ matrix R1 as ( / , / , ) a rotation about axis 1 2 1 2 0 with angle 2 radians. This Figure 7: Graph of ωt  for t ∈ [0,1] choice simplifies the following computations. The logarithms of R0 and R1 are ⎛ ⎞ ⎛ ⎞ 00 0 001 ⎝ ⎠ ⎝ ⎠ logR0 = 00−1 , logR1 = 00−1 01 0 −11 0 and therefore ⎛ ⎞ 00 t ⎝ ⎠ (1−t)logR0 +t logR1 = 00−1 −t 10

We denote this matrix as Lt :=(1 − t)logR0 + t logR1. The next step is to compute the exponential of matrix Lt.Inordertoavoid numerical inaccuracies, we proceed with symbolic computations in Maple [Char et al. 1983] (it would also be possible to use the Ro- drigues formula [Murray et al. 1994], but the equations quickly be- come awkward for manual derivations). Computing the exponential of Lt yields ⎛ √ √ √ ⎞ 2 2 ( ( + 2)− ) 2 1+t cos( 1+t ) − t cos 1 t 1 t sin√( 1+t ) ⎜ 1+t2 1+t2 1+t2 ⎟ ⎜ √ √ √ ⎟ ⎜ t(cos( 1+t2)−1) t2+cos( 1+t2) sin( 1+t2) ⎟ exp Lt = ⎜ − − √ ⎟ ⎜ + 2 + 2 2 ⎟ ⎝ 1 t 1 t 1+t ⎠ √ √ √ ( + 2) ( + 2) − t sin√ 1 t sin√ 1 t cos( 1+t2) 1+t2 1+t2 which is the result of log-matrix blending, denoted as Rt := exp Lt . Now we compute the inverse and derivative of Rt, whose multipli- cation gives the angular velocity matrix M(ωt ), according to For- mula (3). The resulting matrix is indeed anti-symmetric, as ex- pected, and therefore has the structure from Formula (4). If we