To appear in the ACM SIGGRAPH conference proceedings

Spline for Multibody Dynamics

Sung-Hee Lee∗ Demetri Terzopoulos† University of California, Los Angeles

Figure 1: A spline can much more accurately model complex biological joints than is possible using conventional joint models.

Abstract When it comes to designing practical machines, using only the lower pair joints seems reasonable, not because they are ideal Spline joints are a novel class of joints that can model general scle- choices for every mechanism, but because it is difficult to man- ronomic constraints for multibody dynamics based on the minimal- ufacture more complex types of joints. For the same reason, coordinates formulation. The main idea is to introduce spline the creation of more sophisticated joints has been largely ne- curves and surfaces in the modeling of joints: We model 1-DOF glected in multibody dynamics research. Not surprisingly, there- joints using splines on SE(3), and construct multi-DOF joints as fore, most dynamics simulators and game physics engines, such the product of exponentials of splines in Euclidean space. We as ADAMS (www.mscsoftware.com), the Open Dynamics Engine present efficient recursive algorithms to compute the derivatives of (www.ode.org), and SD/FAST (www.sdfast.com), provide only the spline joint, as well as geometric algorithms to determine op- fairly simple types of joint models limited to fixed joint axes. timal parameters in order to achieve the desired joint motion. Our spline joints can be used to create interesting new simulated mecha- By contrast, more complex joints are common in biological sys- nisms for computer animation and they can more accurately model tems. Due to the complicated shapes of bones, biological joints complex biomechanical joints such as the knee and shoulder. usually produce non-trivial movement patterns. For example, the femorotibial joint (Fig. 1) undergoes both rotation and sliding as it CR Categories: I.3.7 [Computer Graphics]: Three-Dimensional is flexed and extended [Kapandji 1974]; it cannot be accurately ap- Graphics and Realism—Animation proximated by a lower pair. While it may be reasonable to approx- imate biological joints, such as those in the neck, by lower pairs when one is interested only in macroscopic joint articulation [Lee Keywords: Biological Joints, Multibody Dynamics, Scleronomic and Terzopoulos 2006], the more accurate analysis and simulation Joints, Splines of biological joint motion is important in biomechanics research and medical applications such as virtual surgery simulation or pros- 1 Introduction thetics design [Delp et al. 1990].

Traditionally, only a few types of elementary joints have been used We propose a technique for modeling general scleronomic joints for to model articulated multibody systems for physics-based anima- multibody dynamics based on the minimal-coordinates (or reduced- tion, robotics, and human movement research. These are the lower coordinates) formulation. The scleronomic joint imposes bilateral, pairs [Reuleaux 1876]; i.e., the prismatic, helical, cylindrical, pla- time-invariant contact constraints. Thus, the relative configuration nar, and spherical joints, and their compounds, such as the universal of the connected bodies is determined wholly by the joint coor- joint. The lower pairs, which are used for modeling most mechan- dinates. While maximal-coordinate dynamics approaches provide ical or biological systems, are characterized by one or more fixed the means to simulate arbitrary scleronomic joint constraints, to axes of rotation or translation. our knowledge ours is the first generalized approach to modeling arbitrary scleronomic joints for multibody dynamics based on the ∗www.cs.ucla.edu/∼sunghee minimal-coordinates approach, which offers important advantages. †www.cs.ucla.edu/∼dt In designing a general scleronomic joint, our key idea is to use splines to model arbitrary, complex joint motions. Hence, we call these spline joints. Specifically, we formulate the 1-DOF (degree of freedom) spline curve joint as the product of exponentials of a twist multiplied by a spline basis function, thus defining an arbi- trary C2-continuous spline motion curve (R → SE(3)) that is free of singularities. We furthermore present geometric data-fitting and smoothing algorithms for 1-DOF spline joint design. Since higher- dimensional, analytically differentiable splines on SE(3) are not yet known, we formulate an n-DOF spline joint as the product of six exponentials of a basis twist multiplied by an n-parameter spline.

1 To appear in the ACM SIGGRAPH conference proceedings

An advantage of spline joints is that one can employ existing joint. One can use this dynamics algorithm without modification to dynamics algorithms without modification. Our technique ex- simulate spline joints (see Appendix A). ploits minimal-coordinates-based dynamics algorithms in modeling general scleronomic constraints. Unlike maximal-coordinates ap- 3 Geometric Preliminaries proaches, the spline joint does not suffer from the “drift problem”. Hence, it does not require a stabilization process, and this allows larger simulation time steps. As the derivatives of the joint up to This section briefly introduces geometric tools derived from Lie the second order are required for dynamics simulation, we provide group theory that we will use in this paper. Readers who are fa- efficient recursive algorithms to compute the analytic joint Jacobian miliar with differential geometry can skip this section. Additional and Hessian. The former also enables the easy computation of the details can be found in [Murray et al. 1994]. inverse kinematics of the joint. Given a moving body frame T(t)=(R,p) ∈ SE(3), where R ∈ ( ) ∈ R3 In addition to enabling the more accurate modeling of biological SO 3 denotes rotation and p translation, its generalized ve- joints, such as the knee shown in Fig. 1, spline joints can also be ap- locity expressed in the instantaneous body frame (hence dubbed the plied in computer graphics to create mechanisms more interesting body velocity) is defined as a twist than those made of simple joints. One has more freedom in design- − [ω] υ ing complex joints for kinematic or dynamic computer animation vˆ = T 1T˙ = , (1) because they need not be easy to manufacture. We apply our spline 00 joint models to create some interesting animated mechanisms. which is an element of se(3), the Lie algebra of SE(3), where ω and υ are, respectively, the angular and linear velocities of T expressed 2 Related Work in the body frame. The 3×3 skew-symmetric matrix of ω is denoted as [ω]. We also represent the twist vˆ as a vector v =[ωT ,υT ]T . The Researchers have endeavored to create complex models of biologi- ∨ operator maps a twist to the corresponding twist coordinate; i.e., cal joints, but no prior effort has provided a suitably complex joint vˆ∨ = v. model that can be used in dynamics simulation. Delp et al. [1990] T T T and Maciel et al. [2002] modeled the knee as a revolute joint whose Given T ∈ SE(3) and g =[ω ,υ ] ∈ se(3), the adjoint mapping −1 joint translates along a parametric curve. Shao and Ng-Thow- AdT :se(3) → se(3) is defined as AdT gˆ = TgTˆ , or in matrix Hing [2003] proposed a general framework for modeling complex form as joints by composing elementary joint components. Their method is R 0 ω Ad g = . (2) useful for forward kinematics, but they too did not consider inverse T [p]RRυ kinematics or dynamics. The adjoint mapping is used in the coordinate transformation of Our work is related to research on spline curves for rotation. The twists. As we will see in Section 4, the body velocity of frame splines on SO(3) that smoothly interpolate rotations are rather in- {i − 1} expressed in frame {i} is written as volved. Shoemake [1985] proposed the interpolation of rotations i using quaternions. Various techniques have been developed to = − , vi−1 AdG 1 vi−1 (3) achieve optimal spline curves in SO(3) that minimize the tangential i acceleration [Gabriel and Kajiya 1985; Barr et al. 1992; Kim et al. where G is the configuration of frame {i} with respect to {i − 1}. 1995; Ramamoorthi and Barr 1997; Park and Ravani 1997]. Since i the interest is in interpolating the rigid motion of a single body, they Another useful operator is the Lie bracket adgˆ :se(3) → se(3) and all rightfully divide the problem on SE(3) into an interpolating ro- it occurs when (2) is differentiated. The Lie bracket is defined as ( ) R3 = − tation in SO 3 and translation in . In contrast, we are interested adgˆ1 gˆ2 gˆ1gˆ2 gˆ2gˆ1,or in the articulated motion of a jointed, multibody system. Hence, we treat rigid-body motion as a screw motion, without decomposing [ω1] 0 ω2 adg g2 = . (4) it into rotation and translation. We adopt the spline algorithms on 1 [υ1][ω1] υ2 SO(3) proposed by Kim et al. [1995] and extend their methods to SE(3) for use in our spline curve joints. Their approach provides a simple form of the derivatives of the spline curve, which makes it The generalized force f =[μT ,ηT ]T is an element of se∗(3), the easier to compute the dynamics of spline joints. dual space of se(3), where μ ∈ R3 represents a moment and η ∈ R3 a force. In matrix form, the corresponding dual adjoint mappings Kry and Pai [2003] introduced a continuous surface contact sim- ∗ ∗ ∗ ∗ ∗ ∗ Ad :se (3) → se (3) and ad :se (3) → se (3) are the transposes ulation technique in a minimal-coordinates dynamics framework. T g of Ad and ad ; i.e., Since they handle general topological surfaces obtained by sub- T g division, the computation of derivatives is more involved. By ∗ = T , ∗ = T . contrast, our method features the efficient computation of deriva- AdT AdT adg adg (5) tives thanks to the structure of the joint representation. T¨andl and −1 R3 = − = Kecskem´ethy [2007] use the Frenet frame of spline curves in for One can easily verify that AdT g AdT 1 g and adgg 0. the dynamics simulation of simple mechanisms. The orientation of the Frenet frame is determined entirely by the spline curve, whereas For all g ∈ se(3), egˆ is an element of SE(3). There exists a closed- the orientation of the frame in our model is independent of its posi- form formula of the exponential map exp : se(3) → SE(3) [Murray tion along the curve, which enables us to model arbitrary rotations et al. 1994]. Note that the derivative of the exponential map is not along the motion curve. Moreover, we use C2-continuous splines, gˆ(t) dgˆ(t) = d gˆ(t) = dgˆ(t) gˆ(t) trivial; e dt dt e dt e in general. However, in the whereas they must use C4-continuous splines. case where the rigid motion is due to a constant twist, its derivative takes the following simple form: Our spline joint can easily be incorporated into current dynamics algorithms. Featherstone [1987] developed an articulated-body dy- d sˆρ( ) sˆρ( ) sˆρ( ) namics algorithm for multiple-DOF joints, such as the universal e t = e t sˆρ˙(t)=sˆe t ρ˙(t). (6) dt

2 To appear in the ACM SIGGRAPH conference proceedings

q; q Generalized coordinate; vector of generalized coords th q˘i The i knot x˙ Differentiation of x with respect to time t x Differentiation of x with respect to q Ti The configuration of frame {i} w.r.t. the inertial frame Gi The configuration of frame {i} w.r.t. its parent frame th G˘ i The i control frame th zi The i control twist vi The body velocity of Ti ui The body velocity of Gi Si The joint Jacobian of frame {i}

Table 1: Frequently used symbols.

Figure 2: An elliptic joint. The child link (green) is constrained to Finally, using the notations defined above, the Newton-Euler equa- slide along the ellipse attached to the parent link (purple). tions of the motion of a rigid body are expressed in a simple form as follows [Park et al. 1995]: The 6 × n joint Jacobian Si is a mapping from the time derivatives = − ∗ , f Jv˙ advJv (7) of the joint coordinates q˙ i to the generalized joint velocity ui. Using (13), the time derivative of vi can be expressed as where f ∈ se∗(3) is the generalized force applied to the rigid body ∈ ( ) = i + + T ∇ + , and v se 3 is the generalized velocity. The generalized inertia v˙i v˙i−1 advi Siq˙ i q˙ i Siq˙ i Siq¨ i (14) J ∈ R6×6 of the rigid body has the following structure: where ∇Si is the joint Hessian. Finally, from (7), the Newton-Euler I m[r] equations of the motion of link i and the joint force or torque τ are J = , (8) m[r]T mI as follows: ∗ i 3×3 f = J v˙ − ad J v + f + − f , , (15) where m is the mass, I ∈ R is the rotational inertia matrix, i i i vi i i i 1 e i r ∈ R3 is the position of the center of mass, and I is the identity τ = T , i Si fi (16) matrix. Eq. (7) is coordinate-invariant; i.e., it holds with respect to ∗ any coordinate frame. where fi ∈ se (3) is the generalized force applied by link i − 1to i f , i Table 1 presents a list of symbols that we will use frequently. link and e i is the external force (e.g., gravity) on link . Note that i = ∗ { } fi+1 Ad −1 fi+1 expresses fi+1 relative to frame i . Gi+1 4 Dynamics of General Scleronomic Joints Based on the above Lie group theoretic formulation of the kinemat- ics and dynamics equations of general scleronomic joints, we derive With the geometric tools introduced in Section 3, we will now de- in Appendix A an O(n) recursive forward dynamics algorithm for rive the kinematics and dynamics equations for general scleronomic simulating such joints. joints, including the lower pair joints. Assuming that link i of a multibody system is connected to its par- 4.1 Creating New Joints ent link i − 1 via a joint, the configuration Ti ∈ SE(3) of the body frame {i} of i with respect to the inertial reference frame is According to (9)–(16), the joint transformation as well as its Ja- cobian and Hessian are necessary for the kinematic analysis and Ti = Ti−1Gi, (9) dynamic simulation of the system. Hence, to create a new joint, it suffices to define a twice-differentiable joint transformation and its where Ti−1 is the configuration of {i − 1}, and Gi denotes the rela- derivatives. Before defining new joints, consider the joint transfor- tive configuration of {i} with respect to {i − 1}, which we will call mation, Jacobian, and Hessian of some simple joints. the joint transformation. It is determined by the action of the joint and, for scleronomic joints, it is determined entirely by the joint co- The helical joint with pitch h has a joint transformation in the form n =[ , , , , , ]T ordinate qi ∈ R , where n is the number of DOFs of the joint; i.e., of an exponential of a twist of a screw parameter s 0 0 1 0 0 h sˆq Gi = Gi(qi). The generalized joint velocity generated by the action multiplied by a joint coordinate q ∈ R; i.e., G(q)=G(0)e . Using of the joint is (13), we can derive the joint Jacobian and Hessian as S = s and = −1 ˙ . ∇S = 0. Thus, the joint Jacobian of the helical joint is constant and uˆ i Gi Gi (10) it is actually the screw parameter of the joint. Substituting (9) into (1), we can express the body velocity vi as the velocity of link i − 1 plus that of the joint: The universal joint can be modeled as the product of two revo- sˆ q sˆ q lute joints, G = G(0)e 0 0 e 1 1 . Here, the joint Jacobian is S = i − ∗ ∗ = − + . 1 =[ ] vi vi 1 ui (11) Ad s1q1 s0s1 : s0 s1 , where s0 is the instantaneous screw param- e ∗ eter at given q , and an element of the Hessian is ds /dq = ad ∗ s . 1 0 1 s0 1 For scleronomic joints, Note that the joint Jacobian is not constant, but is a function of the joint coordinates, which is typically the case for multi-DOF joints. ui(qi)=Si(qi)q˙ i, (12) ∨ Next, consider the creation of a non-conventional joint; for exam- dG ( )= −1 i . ple, an elliptic joint (Fig. 2) that constrains the child link to slide where Si qi Gi (13) dqi along an ellipse with its orientation tangential to the ellipse. The

3 To appear in the ACM SIGGRAPH conference proceedings joint transformation G(q) can be written as follows: While arbitrary C2-continuous splines may be used for our pur- poses, consider B-splines of order k > 3 as a concrete example. Let e[k]φ(q) (a q,−b q, )T G(q) ∈ SE(3) be a joint transformation parameterized by q ∈ R. G(q)=H sin cos 0 , (17) 10 Using the cumulative B-spline basis, G(q) can be expressed as the φ( )= ( , ), product of exponentials of a constant control twist z multiplied by q atan2 bsinq acos q (18) a spline basis function where a and b are the semi-axes of the ellipse, and k is a unit vec- m R3 zˆ j B˜ j,k(q) tor in . Once the joint transformation is defined, we must com- G(q)=G˘ 0 ∏ e , (21) pute the Jacobian and its derivative to perform dynamic simulation. j=1 From (10) and (12), −1 where z j = log(G˘ − G˘ j). The cumulative basis function is defined −[kˆ ]φ T T j 1 S =[φ k, e [acosq, bsinq, 0] ] , (19) ˜ ( )=∑m ( ) as the sum of B-spline basis functions: B j,k q = j B,k q . The dS −[ˆ ]φ ˘ =[φ k, e k [(bφ − a)sin q, (b − aφ )cosq, 0]T ]T . (20) control frame G j corresponds to control point j in the regular B- dq spline function. Kim et al. [1995] show that the B˜ j,k(q) are non- constant only forq ˘ < q < q˘ + − : Since the desired joint motion is complex, defining such a joint j j k 1 transformation in closed form becomes difficult. ⎧ ⎨⎪0ifq ≤ q˘ j Ideally, it should be easy to compute the derivatives of the joint j+k−2 B˜ , (q)= ∑ B, (q) ifq ˘ j < q < q˘ + − (22) j k ⎩⎪ = j k j k 1 transformation. Since splines can effectively model complex curves ≥ and surfaces, it is natural to apply them in modeling complex joints. 1ifq q˘ j+k−1 and that their derivatives take the simple form 5 Spline Joints − d ˜ ( )= k 1 ( ). We now introduce the spline joint, a novel class of scleronomic B j,k q B j,k−1 q (23) dq q˘ j+k−1 − q˘ j joints whose joint transformation is modeled using splines. Any splines may be used for the joint transformation, as long as the fol- ˜ ( ) − ˜ ( ) − zˆ1B1,k q = ˘ 1 ˘ zˆ j−k+1B j−k+1,k q = ˘ 1 ˘ lowing two requirements are satisfied: From (22), e G0 G1, ..., e G j−kG j−k+1, ˜ ( ) ˜ ( ) and ezˆ j+1B j+1,k q = ··· = ezˆmBm,k q = I. This greatly reduces the 1. The spline joint G(q) must be C2-continuous in order to main- number of multiplications and we can express the joint transforma- tain the boundedness of the joint acceleration. tion as the product of only k − 1 exponentials: 2. The joint Jacobian S(q) must not vanish anywhere in the do- j main, because the generalized joint velocity will vanish where ˜ ( ) ( )= ˘ zˆB,k q . S(q)=0, even for non-zero joint coordinate velocity q˙. G q G j−k+1 ∏ e (24) = j−k+2 Conceptually, we create the spline joint by defining the joint trans- formation matrix in SE(3) as a function of joint coordinates (an We can also see that the joint transformation is locally defined by k n-dimensional vector) using splines, and subsequently deriving its control frames, G˘ j−k+1,...,G˘ j. In the case of the cubic B-spline, derivatives up to order two. However, since SE(3) is a curved space, the joint transformation can be expressed as the product of just three it is by no means trivial to apply splines to the modeling of joint exponentials. transformations. We employ the spline curves of Kim et al. [1995] in the modeling of 5.2 Multi-DOF Spline Joint 1-DOF spline joints. Their spline curves in SO(3) can be straight- forwardly extended to SE(3) in which our spline curve joints are de- Unfortunately, the spline curve on SO(3) does not naturally extend fined. However, higher-dimensional splines (e.g., spline surfaces) to the spline surface, let alone the spline surface on SE(3).An on SO(3) are not yet known.1 Hence, to create multi-DOF spline alternative is to model the joint transformation as the product of joints, we apply splines defined in Euclidean space to the twist co- exponentials of six basis twists eˆ1,...,eˆ6: ordinates. 6 φ ( ) G(q)=H ∏ eeˆ j j q , (25) 5.1 Spline Curve Joint j=1 ( ) The general interpolation scheme for SO 3 developed by Kim et where φ (q) : Rn → R is an n-DOF spline in Euclidean space. Even k−2 th j al. [1995] achieves C -continuous rotation curves for k -order though (25) is similar in structure to (21), the two are quite differ- splines by introducing a cumulative form of the splines basis func- ent; in the spline curve joint, the spline is defined in the SE(3) world tions and the product of their exponentials. The merit of their space, whereas in multi-DOF joints the spline is defined in each di- method from the perspective of joint modeling is that the deriva- mension of se(3). tives are easy to compute. The extension from the spline curve on SO(3) to SE(3) is straightforward and it retains all the important It is generally advantageous to use the first three basis twists to rep- features such as local support and Ck−2 continuity. resent the translation component of the joint transformation, while the last three represent the rotation. This is equivalent to represent- 1Alexa [2002] defined an SE(3) curve as an exponential of a spline curve ing the rotation using Euler angles, which suffers from singularities in Euclidean space. Similarly, a spline surface on SE(3) can be defined as in certain configurations. Therefore, this approach cannot cover the an exponential of a spline surface in Euclidean space, but in general the whole of SO(3). However, in many cases we can choose suitable derivatives of such a surface cannot be computed analytically. Euler angles to avoid singularities in the presence of joint limits.

4 To appear in the ACM SIGGRAPH conference proceedings

5.3 Derivatives of the Spline Joint Transformation 6.2 Data Fitting Algorithm

For both the spline curve joint and the multi-DOF spline joint, the k k = Given a series of desired joint transformations Gd at q for k joint transformation G(q) takes the form of a product of exponen- 1,...,N, the goal of the data fitting process is to compute optimal tials. Having defined the joint transformation, we must then com- control frames G˘ 0,...,G˘ m such that pute its Jacobian and Hessian for the purposes of dynamics simu- lation. An important feature of spline joints is that the twists are N ( k , ( k)), constant, which enables us to compute the analytic joint Jacobian argmin ∑ d Gd G q (32) ˘ ... ˘ = and its derivatives efficiently as follows. The n-DOF spline joint G0 Gm k 1 (n ≥ 1) has the following form: (·,·) ( ) m where d is a metric on SE 3 . We can solve this nonlinear φ ( ) G(q)=H ∏ egˆ j j q , q ∈ Rn, (26) optimization problem by iteratively updating control frames such j=1 that the value of the objective function decreases. Imagine that the G˘ φ ∈ R control frames j (and spline) are moving in space and that at each where j is some function of the joint coordinates q and where − iteration we update G˘ using the body velocity u˘ = G˘ 1G˘˙ , so that gˆ j ∈ se(3), a constant, is a control twist for the spline curve joint j j j j ( k) k or a basis twist for the n-DOF joint. Given the joint transformation, G q approaches Gd. To this end, we need the mapping from the the joint Jacobian consists of n twists; i.e., S =[s1,...,sn], where velocities of the control frames to the velocities of the joint trans- k ∂ ∨ m ∂φ formations at q . −1 G −1 k s = G = ∑ Ad φ g . (27) i egˆk+1 k+1 ···egˆmφm k ( )= ∂qi = ∂qi For simplicity, let us consider the cubic B-spline case: G q k 1 γ β α G˘ j−3e e e , where γ = B˜ j−2zˆ j−2, β = B˜ j−1zˆ j−1, and α = B˜ jzˆ j Eq. (27) can be computed efficiently in a recursive manner: −1 forq ˘ j ≤ q < q˘ j+1. From the relation z˙ j = u˘ j −Ad z u˘ j−1, we make = μi , e j si m (28) the following approximation: where μi = 0 and 0 ∨ ∂φ −α d α ≈ ˜ − −1 . i k −1 i e e B j u˘ j Adeα u˘ j−1 (33) μ = g + φ μ ≤ k ≤ m k k Ad gˆk k k−1 for 1 . (29) dt ∂qi e Its derivatives are also expressed recursively: Then, the velocity of the joint transformation at q can be expressed neatly as the sum of the velocities of control frames weighted by ∂s ∂μi i = m , (30) the (regular) B-spline basis functions: ∂q j ∂q j ( ) ≈ −1 + −1 where u q B j−3Ad γ β α u˘ j−3 B j−2Ad β α u˘ j−2 e e e e e (34) ∂μi ∂ 2φ ∂μi ∂φ + −1 + . k k −1 k−1 k B j−1Adeα u˘ j−1 B ju˘ j = g + Ad φ + ad i g . (31) k gˆk k μ k ∂q j ∂qi∂q j e ∂q j k−1 ∂q j k Using (34), we construct a matrix that relates the u˘ j to the u(q ): Appendix B gives pseudo code for computing the joint derivatives. Mu˘ c = ud, (35) 6 Designing Spline Curve Joints =( T ,..., T )T ∈ R6(m+1) where M is a banded matrix, u˘ c u˘ 0 u˘ m , and 1 T N T T 6N A spline joint can be designed either by directly specifying the con- the desired velocities ud =(u(q ) ,...,u(q ) ) ∈ R . trol frames or by providing a series of joint transformations for the ( k) k spline joint to interpolate. For example, to model a biological joint For G q to approach Gd , we construct M, specify ud by setting as a spline joint, one can measure the relative transformations of ( k)= ( ( k)−1 k ), the two bones in sample configurations and model a spline joint u q log G q Gd (36) that optimally interpolates between the estimated transformations. u˘ We will present a geometric data fitting algorithm to determine the solve the linear system (35) for u˘ c, and update G˘ j ← G˘ je j , for control frames in this scenario. We will focus on the 1-DOF spline j = 0,...,m, thus decreasing the value of the objective function in curve joint. Data fitting for the multi-DOF spline joint is left for (32). We iterate these steps until convergence in order to solve the future work, as will be discussed in Section 8. optimization problem.

6.1 Natural Parameterization 6.3 Smoothing Algorithm

Given a set of control frames, we want to construct the spline joint When the desired joint transformations are noisy, the resulting by assigning knot valuesq ˘0,...,q˘m to each control frame. While we spline joint can produce unnatural motion. In this case, we need can assign arbitrary ascending numbers to the knot values, a more to smooth the spline curve in order to improve the quality of mo- intuitive choice would be setting the knot values in such a way that tion. An approach defining the smoothness of the spline joint is the distance between two frames equals the distance in the joint through the joint Hessian: If it is zero, the joint axis is fixed and coordinate space; i.e., ||δG|| = ||δq|| or, equivalently, ||s(q)|| = 1. produces simple motion like that of the lower pair joints. As in the Note that since a twist contains both linear and angular motions, one data fitting algorithm, we compute the relationship between the rate should define a suitable metric for a particular application. While it of change of the joint Hessian at each point and the velocities of the is difficult to ensure ||s(q)|| = 1 for all q, it is easy to get approxi- −1 2 metric for dynamics simulation. The unweighted metric is in some sense mate results by settingq ˘ j = q˘ j−1 + ||log(G − G j)||. j 1 a geometrically reasonable one and it may give a better sense of distance 2Here we employ the “unweighted” metric, but any reasonable metric to users, while the inertia-weighted metric may be better for modeling con- can be used. For example, Kaufman et al. [2005] used the inertia-weighted trollers.

5 To appear in the ACM SIGGRAPH conference proceedings

Figure 3: Knee spline joint inverse kinematics example. control frames, and then we update the control frames in such a way that the joint Hessians approach zero. We give a slightly different approximation to (33) for simplicity:3 ∨ −α d α −1 e e ≈ α˙ = B˜ u˘ − Ad z u˘ − . (37) dt j j e i j 1

Using (37), we can write the time derivative of the joint Hessian (a vector) as ˙ ≈ − −1 + − −1 h N − Ad zˆ u˘ j−3 N − N − Ad zˆ u˘ j−2 j 2 e j−2 j 2 j 1 e j−1 (38) + − −1 + , Figure 4: Sample poses (top) and closeup internal view (bottom) N − N Ad zˆ u˘ − N u˘ j j 1 j e j j 1 j of the scapulothoracic joint, modeled as a spline surface joint.

−1 where N − = B˜ , j 2 j−2Adeβ eα (39) −1 −1 eye in a commercial modeling package, then applying the data fit- N − = B˜ Ad α + B˜ − Ad adγ , (40) j 1 j−1 e j 1 eβ eα ting and smoothing algorithms to generate the control frames. As −1 N j = B˜ I + B˜ jAd α ad −1 . (41) the accompanying video shows, data-fitting without smoothing cre- j e (β +Ad β γ ) e ates a somewhat unnatural motion. We achieve a more natural mo- tion after applying the smoothing algorithm. One can derive the analytic derivatives of the Nj, but numerical differentiation with respect to q is also simple and effective. Fig. 3 demonstrates that inverse kinematics algorithms can be ap- As in the data fitting case, we construct a matrix that transforms plied to the spline joint. Given a target position and orientation the velocities of the control frame to the rate of change of the joint of the foot, an iterative inverse kinematics algorithm uses the ana- Hessian: lytic Jacobian to compute the joint coordinates of the leg required Nu˘ = h˙ . (42) to reach the target configuration. The hip and the ankle are modeled c d as revolute joints. We can incorporate the smoothness criterion into the data fitting 2 2 The scapulothoracic joint in the shoulder is a notorious joint to process by minimizing (1 − w)||ud − Mu˘ c|| + w||h˙ d − Nu˘ c|| , model in biomechanics. Fig. 4 demonstrates that it can be mod- which can be accomplished by solving for u˘ c in eled as a spline surface joint. The scapula is connected to the rib cage via a 2-DOF spline surface joint and to the clavicle via (1 − w)MT M + wNT N u˘ =(1 − w)MT u + wNT h˙ , c d d damped springs. Our approach is contrary to conventional methods in which the clavicle and the scapula form a kinematic hierarchy where w is a weight and h˙ d can simply be set to −ch for 0 < c ≤ 1. via a ball joint and auxiliary constraints enforce the contact be- tween the scapula and the . Since we model the spline surface The smoothing algorithm can also be used to smooth the spline such that the pose of the scapula satisfies the constraint between the curve while interpolating desired joint transformations by provid- scapula and the clavicle (i.e., the distance between the acromion ing more control frames than are necessary for interpolation; i.e., process and the is approximately the same as since the number of control frames exceeds the minimum number the length of the clavicle), it is easy to enforce the constraint be- required for interpolation, the extra control frames provide addi- tween the scapula and the clavicle using springs. The gray surface tional degrees of freedom to achieve smoothness. between the scapula and the rib cage in Fig. 4 is the surface swept by the reference frame of the scapula. The orientations of the frame 7 Examples and Results at sample positions are drawn on the surface. The red box on the surface represents the current position and orientation. Fig. 1 shows the femorotibial joint modeled as a spline curve joint. We created the desired joint transformations by posing the tibia by Fig. 5 illustrates some of our experiments in creating interesting mechanisms using spline joints. In Fig. 5(a), each of the three beads α 3 −α de = α + 1 [ α,α ]+ 1 [[α,α ],α ]··· is connected to the parent link through a flower-shaped spline joint. Note that e dt ˙ 2! ˙ 3! ˙ , where the Lie bracket [ α,α˙ ] := αα˙ − αα˙ . Therefore, the approximation approaches the In this example, the beads slide along the spinning wire frame in a exact solution when α˙ is either small or parallel to α. physically realistic manner in gravity (we can easily enable them to

6 To appear in the ACM SIGGRAPH conference proceedings

msec for the 8-DOF system “SIGGRAPH Joint 1”. Since we use local-support basis splines, the number of control points does not adversely affect the computational complexity.

8 Conclusion and Future Work

We introduced spline joints to model general scleronomic joints for multibody dynamics based on the minimal-coordinates formu- lation. Spline joints enable the accurate modeling of biological joints, as well as the creation of interestingly intricate mechanisms for computer graphics. Spline joints can easily be incorporated into existing dynamics algorithms. Our technique opens up a range of (a) Beads-on-a-Wire (b) Globe possibilities in modeling dynamic structures and it nicely avoids the slower maximal-coordinates-based approach that, anyway, would not simplify the representation of the scleronomic constraint. Many complex biological joints of animals (including humans) can be more accurately modeled using our technique. For example, we demonstrated that the femorotibial joint and the scapulothoracic joint can be modeled more accurately using spline joints. We mod- eled these knee and shoulder examples by eye; more accurate mod- eling should be possible using medical imaging techniques. In the case of human joints other than the knee and scapula, the types (e.g., the ) and saddle joint types (e.g., the ) should benefit most from our technique.

(c) SIGGRAPH Joint (d) Deforming Spline Surface Joint Since we use twice differentiable splines in spline joints, our tech- nique can best be used for modeling “smooth” joints. However, we believe that sharp corners can be reasonably approximated in most Figure 5: Example mechanisms modeled with spline joints. cases by smooth splines using multiple control frames near the dis- continuities. If one wants to model sharp corners or cusps using non-C2-continuous splines, it would be necessary to compute and spin freely about the curve by inserting a simple rotational joint be- apply an appropriate impulse at the discontinuities. tween the bead and the spline joint). Similarly, Fig. 5(b) illustrates a As demonstrated in the “SIGGRAPH Joint 2” example, surface-to- mechanism in which toy airplanes slide along the continental coast- surface contact can be simulated by multiplying one spline surface lines using spline joints. Note that for the “Globe” example, each joint with a second “inverted” spline surface joint. Moreover, it is control frame is computed such that two of its axes are in the tan- possible to enforce additional constraints, such as a no-slip con- gent plane of the globe and one of those two axes is also tangent straint, by computing constraint forces using Lagrange multipliers. to the coastal curve. The “Beads-on-a-Wire” example is created in a similar manner. These examples demonstrate that we can create We did not consider the data fitting problem for multi-DOF joints. spline joints of arbitrary shape. A naive approach would be to apply least-squares fitting to each of 6 splines because, unlike the 1-DOF case, each spline is defined in Fig. 5(c) is a snapshot from the “SIGGRAPH Joint 1” demo in the Euclidean space. Presumably this coordinate-wise fitting will give accompanying video. In this example, we use spline joints to con- reasonable results; however, it may not be optimal in terms of the strain each letter to the surface of the parent letter. The chain of given metric on SE(3). A good problem for future work would be letters, which is constrained at the top of the letter S, free-falls in to develop an optimal data fitting algorithm for multi-DOF spline gravity. As we modeled only a single spline joint between a pair of joints that respects the metric on SE(3). letters, the contact point of one of the two links is constant while that of the other is changing. In the second “SIGGRAPH Joint 2” In the deforming spline surface joint example (Fig. 5(d)), we de- example in the accompanying video, we allow sliding on both sur- formed the surface spline kinematically and the surface itself did faces by modeling two spline curve joints between the letters. The not participate in the dynamic simulation. In future work, however, first curve is created from the tangent frames while the second is there is no reason why we cannot employ dynamic NURBS [Ter- created from the inverse of the original control frames. zopoulos and Qin 1994] to create an physically accurate D-NURBS surface joint which would deform elastically under the weight of the Fig. 5(d) is an example of a “Deforming Spline Surface Joint”. The ball or any other applied forces. cyan sphere is constrained to slide along a 2-DOF spline surface joint in a physically realistic manner, subject to gravity. At the same time, the spline surface joint deforms kinematically. A Recursive Forward Dynamics Algorithm

We performed our experiments on a 2.6 GHz Intel Core 2 CPU For use with our spline joints, we derive a Lie Group theoretic re- system. The spline joint permits large numerical time steps using cursive dynamics formulation that extends the one in [Park et al. the forward Euler time integration method. In our experiments, the 1995]. Note that the algorithm is essentially the same as the articu- maximum time step ranges from 20 msec (“Globe”) to 100 msec lated body method for multiple DOF joints developed in [Feather- (“Beads-on-a-Wire”). Also, the experiments confirm that the spline stone 1987]. Our recursive forward dynamics algorithm is O(n) for joint does not raise the complexity of the dynamics formulation be- tree-type articulated structures. yond O(n). With our unoptimized implementation, the compute time per time step is 6 msec for the 1-DOF system “Knee” and 49 The articulated inertia J˜i and its associated bias force bi are defined

7 To appear in the ACM SIGGRAPH conference proceedings such that they satisfy the following relation: BARR, A. H., CURRIN, B., GABRIEL, S., AND HUGHES,J.F. 1992. Smooth interpolation of orientations with angular velocity fi = J˜iv˙i + bi. (43) constraints using quaternions. In Computer Graphics (Proceed- ings of SIGGRAPH 92), 313–320. T Substituting (14) into (43) and pre-multiplying (43) with Si ,we DELP, S. L., LOAN,J.P.,HOY, M. G., ZAJAC, F. E., TOPP, τ can decompose q¨ i into two parts, one induced by i and the other E. L., AND ROSEN, J. M. 1990. An interactive graphics-based induced by neighboring joints, as follows: model of the lower extremity to study orthopaedic surgical pro- cedures. IEEE Transactions on Biomedical Engineering 37,8 = Ω−1 τ − T ˜ (i + ) − T , q¨ i i i Si Ji v˙i−1 ci Si bi (44) (Aug.), 757–767. FEATHERSTONE, R. 1987. Robot Dynamics Algorithms. Kluwer = T ∇ + Ω = T ˜ Adademic Publishers, Boston. where ci q˙ i Siq˙ i advi ui and i Si JiSi. We want to derive recursive equations for J˜i and bi. This is accomplished by replac- GABRIEL, S., AND KAJIYA, J. 1985. Spline interpolation in ing fi+1 in (15) with (43) and substituting (14) for v˙i+1. Hence, we curved space. In SIGGRAPH 85 Course Notes for “State of the derive the recursive forward dynamics algorithm for general scle- Art in Image Synthesis”. ronomic joints as follows: KAPANDJI, I. 1974. The Physiology of the Joints. Churchill Liv- ingstone, Edinburgh. • Given τi and fe,i • Update Gi, Si, ∇Si, vi and ci KAUFMAN, D. M., EDMUNDS,T.,AND PAI, D. K. 2005. Fast • Backward recursion: frictional dynamics for rigid bodies. ACM Transactions on Graphics 24, 3 (Aug.), 946–956. ˜ = + ∗ ˜ Ji Ji Ad −1 Ji+1AdG−1 Gi+1 i+1 KIM, M.-J., SHIN,S.Y.,AND KIM, M.-S. 1995. A general − ∗ ˜ Ω−1 T ˜ construction scheme for unit quaternion curves with simple high Ad −1 Ji+1Si+1 i+1Si+1Ji+1AdG−1 Gi+1 i+1 order derivatives. In Proceedings of SIGGRAPH 95, Computer ∗ ∗ Graphics Proceedings, Annual Conference Series, 369–376. = − − , + − (˜ + + + + ) bi advi Jivi fe i Ad 1 Ji 1ci 1 bi 1 Gi+1 KRY, P. G., AND PAI, D. K. 2003. Continuous contact simulation ∗ −1 T + − ˜ + + Ω τ + − (˜ + + + + ) for smooth surfaces. In ACM Transactions on Graphics, vol. 22, AdG 1 Ji 1Si 1 i+1 i 1 Si+1 Ji 1ci 1 bi 1 i+1 106–129. Ω = ST J˜ S i i i i LEE, S.-H., AND TERZOPOULOS, D. 2006. Heads up! Biome- chanical modeling and neuromuscular control of the neck. ACM • Forward recursion: Transactions on Graphics 25, 3 (July), 1188–1198. = Ω−1 τ − T ˜ (i + ) − T MACIEL, A., NEDEL,L.P.,AND FREITAS, C. M. D. S. 2002. q¨ i i Si Ji v˙i−1 ci Si bi i Anatomy-based joint models for virtual human skeletons. Pro- i v˙i = v˙i−1 + ci + Siq¨ i ceedings of the Computer Animation 2002 Conference, 220–224. MURRAY, R., LI, Z., AND SASTRY, S. 1994. A Mathematical Introduction to Robotic Manipulation. CRC Press, New York. B Spline Joint Jacobian and Hessian PARK, F. C., AND RAVANI, B. 1997. Smooth invariant interpo- =[ ,..., ] lation of rotations. ACM Transactions on Graphics 16, 3 (July), Elements of the joint Jacobian S s1 sn and the Hessian are 277–295. computed using the following algorithm: Require: q PARK, F. C., BOBROW, J. E., AND PLOEN, S. R. 1995. A lie ∂φ ∂ 2φ group formulation of robot dynamics. The International Journal 1 ∂si 1 1: si = g1 , = g1 for i, j = 1,...,n ∂qi ∂q j ∂qi∂q j of Robotics Research 14, 6, 609–618. 2: for k = 2tom do ∂ ∂ 2φ − ∂ ∂φ RAMAMOORTHI, R., AND BARR, A. H. 1997. Fast construction si = k + 1 si + k 3: gk Ad g φ ads gk ∂q j ∂qi∂q j e k k ∂q j i ∂q j of accurate quaternion splines. In Proceedings of SIGGRAPH ∂φ = k + −1 97, Computer Graphics Proceedings, Annual Conference Series, 4: si gk ∂ Ad g φ si qi e k k 287–292. Refer to Section 5.3 for the definitions of the symbols. The com- REULEAUX, F. 1876. Kinematics of Machinery: Outlines of a plexity of this algorithm is O(n2m), where n is the number of DOFs Theory of Machines. MacMillan and Co, London. of the joint and m is the number of exponentials. In most cases, m SHAO,W.,AND NG-THOW-HING, V. 2003. A general joint com- is small (e.g., m = 3 for the 1-DOF cubic spline joint) and n ≤ 2, so ponent framework for realistic articulation in human characters. this algorithm is efficient. In Proceedings of the 2003 ACM Symposium on Interactive 3D Graphics, 11–18. Acknowledgements SHOEMAKE, K. 1985. Animating rotation with quaternion curves. In Computer Graphics (Proceedings of SIGGRAPH 85), 245– SHL was supported in part by a UCLA Dissertation Year Fellow- 254. ship. The knee mesh data was created by Marco Viceconti and TANDL¨ , M., AND KECSKEMETHY´ , A. 2007. A comparison of B- is available from www.tecno.ior.it/VRLAB. We acknowledge the spline curves and Pythagorean hodograph curves for multibody helpful comments of the anonymous referees. dynamics simulation. Proceedings of Twelfth World Congress in Mechanism and Machine Science (June), 380–387. References TERZOPOULOS, D., AND QIN, H. 1994. Dynamic NURBS with geometric constraints for interactive sculpting. ACM Transac- LEXA ACM A , M. 2002. Linear combination of transformations. tions on Graphics 13, 2 (Apr.), 103–136. Transactions on Graphics 21, 3 (July), 380–387.

8