Pump It Up: Computer Animation of a Biomechanically Based Model of Muscle using the Finite Element Method by David Tzu-Wei Chen MSEE, Stanford University (1983) BSEE, University of Illinois (1981) Submitted to the Media Arts and Sciences Section, School of Architecture and Planning, in partial fulfillment of the requirements for the degree of Doctor of Philosophy at the of Technology Institute Massachusetts February 1992 of Technology, 1991. All rights reserved. Institute @Massachusetts Author David Chen Media Arts and Sciences Section October 18, 1991 Certified by AssociteesDa Associate Professor Compu Media Arts an Accepted by id Zeltzer r Graphics ciences Section . Stephen A. Benton Chairperson, Departmental Committee on Graduate Students MASSACHUSETTS WNSTITUTE OF TECHNOLOGY APR 28 1992 David T. Chen Pump It Up: Computer Animation of a Biomechanically Based Model of Muscle using the Finite Element Method by David Tzu-Wei Chen Submitted to the Media Arts and Sciences Section, School of Architecture and Planning on October 18, 1991 in partial fulfillment of the requirements for the degree of Doctor of Philosophy Abstract This thesis examines muscle function through the process of making computer animation and developing interactive graphics applications. Muscle is the fundamental "motor" that drives all animal motion and so is an appropriate place to begin investigations relevant to the goal of modeling human characters. The major supposition of the thesis is that the shape changes generated by a contracting muscle will be reproduced by accurately simulating the forces involved. To examine the hypothesis, a novel computational model of skeletal muscle is presented. The geometry and underlying material properties of muscle are captured using the finite element method (FEM). A biomechanical model of muscle action is used to apply non-linear forces to the finite element mesh nodes. The techniques that are developed for fast graphical display and interactive manipulation of finite element simulations can be used both to design computer animations and directly incorporated into new kinds of applications-such as surgery simulation systems-made possible by the ever increasing power of computer workstations. Results presented indicate that the twin goals of realistic computer animation and valid biomechanical simulation of muscle can be met using the methods presented herein and can be a foundation both for animators wishing to create anatomically based characters and biomechanical engineers interested in studying muscle function. Thesis Supervisor: David L. Zeltzer Title: Associate Professor of Computer Graphics This work was supported by NHK and by equipment grants from Hewlett-Packard. Pump It Up David T. Chen 3 Thesis Committee Chairman \ David Zeltzer Comp er Graphics Associate ofessor MIT Media rts and Sciences Section Member Joe Rosen Associate Professor in Plastic and Reconstructive Surgery Dartmouth Medical School Member. U Pump It Up John Williams Associate Professor MIT Department of Civil Engineering 4 David T. Chen Contents 1 2 3 Introduction 1.1 Previous Work . . . . . . . . 1.2 Elastic objects . . . . . . . . . 1.3 Goals and Contributions . . . . . . . . 1.4 Thesis Organization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Modeling a Single Muscle 2.1 Basic Muscle Anatomy . . . . . . . . . . . . . 2.2 Muscle Force . . . . . . . . . . . . . . . . . . Sliding Filament Theory of Contraction 2.2.1 . . . . . . . . . . Hill's Force Model 2.2.2 Zajac's Force Model . . . . . . . . . . 2.2.3 2.3 Muscle Shape . . . . . . . . . . . . . . . . . . Range Camera Data . . . . . . . . . . 2.3.1 Manual Shape Input . . . . . . . . . . 2.3.2 Contour Data . . . . . . . . . . . . . . 2.3.3 2.4 Simulating a Muscle . . . . . . . . . . . . . . The Finite Element Method Equilibrium Equations . . . . . . 3.1 . . Stiffness Matrix K . . . . 3.1.1 . Mass Matrix M . . . . . . 3.1.2 . . . . Interpolation 3.2 Isoparametric . Stiffness Matrix . . . . . . 3.2.1 . Computer Graphics . . . . 3.2.2 . Global Matrix Assembling . . . . 3.3 . 3.4 Modal Analysis . . . . . . . . . . iations . Eq Equilibrium the Solving 3.4.1 . The Modal Transformation 3.4.2 . . . . . Graphics Computer 3.4.3 3.4.4 Deriving Modal Forces . . . . . . . . . u . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 60 60 67 68 68 77 85 88 88 90 94 96 CONTENTS Up It Up Pump It CONTENTS David T. Chen 3.4.5 4 5 Implementation 5.1 The 3d Animation/Dynamic Simulation Tcl Language Synt ax . . . . . . 5.1.1 . . . . . . . . 3d Data Types 5.1.2 5.2 Graphics and Rendering . . . . . . . . Objects . . . . . . . . . . . . . 5.2.1 Camera . . . . . . . . . . . . . 5.2.2 Lights . . . . . . . . . . . . . . 5.2.3 5.4 5.5 5.6 5.7 7 . . . . . . . . . . . . . . . . . . . . . . . . . . . . Musculoskeletal Structure 4.1 Skeleton Kinematics . . . . . . . . . . Denavit and Hartenberg Joints 4.1.1 Inverse Kinematics . . . . . . . 4.1.2 4.2 Muscle Coordination . . . . . . . . . . 4.3 Attachments, Collisions and Constraints 5.3 6 Mode Truncation . . . . . . . . . . . . . . . . . . . 104 105 105 108 110 113 . . . . . System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Rendering . . . . . . . . . . . . . . . . . . 5.2.4 Numerical Math . . . . . . . . . . . . . . . . . . . Matrix Functions . . . . . . . . . . . . . . 5.3.1 Netlib Functions . . . . . . . . . . . . . . 5.3.2 Dynamic Objects . . . . . . . . . . . . . . . . . . User Interface . . . . . . . . . . . . . . . . . . . . Motif Widgets . . . . . . . . . . . . . . . . 5.5.1 . . . . . . . . . . . . . . . . . . X Events 5.5.2 User-Assisted Finite Elem ent Mesh Construction Validating the FEM Imple mentation . . . . . . . Methods and Results Frog Gastrocnemius Simulation . . . . . . . . . 6.1 Force-based Finite Element Muscle Model 6.1.1 Tension-Length Experiment . . . . . . . 6.1.2 Quick Release Experiment . . . . . . . . 6.1.3 Human Gastrocnemius Simulation . . . 6.1.4 Future Work . . . . . . . . . . . . . . . 6.1.5 6.2 Computer Animation . . . . . . . . . . . . . . . Using the FEM for Computer Animation 6.2.1 Jell-O@ Dynamics . . . . . . . . . . . . 6.2.2 GED Puff . . . . . . . . . . . . . . . . . 6.2.3 Conclusions 98 116 116 118 120 121 122 122 123 124 124 125 126 127 129 129 131 132 137 144 144 146 154 157 158 162 166 166 167 170 172 CONTENTS Up It Up Pump It CONTENTS David T. Chen U A Isoparametric Interpolation 180 B Fast Interpolation 186 It Up Up Pump It CONTENTS CONTENTS T David T. Chen List of Figures 2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.17 2.18 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 A whole muscle adapted from [Kel7l] . . . . . . . . . . . . . . . . . . . . . Section of muscle [Kel7l] . . . . . . . . . . . . . . . . . . . . . . . . . . . . The myofibril in relaxed and contracted states [Kel7l] . . . . . . . . . . . Longitudinal muscles [Kel7l] . . . . . . . . . . . . . . . . . . . . . . . .. Peniform muscles [Kel7l] . . . . . . . . . . . . . . . Comparison of longitudinal and penniform shortening . . . . . . . . . . . Physiological cross section adapted from [Kel7l] . . . . . . . . . . . . . . . Electron micrograph showing three myofibrils in a single muscle fiber [VSL Changes in fiber banding pattern due to contraction [VSL75] . . . . . . . Tension-length curves . . . . . . . . . . . . . . . . . . . . . . . . . . . .. Gasser and Hill quick-release apparatus [GH24] . . . . . . . . . . . . . . . Quick-release curves, plotting tension versus time [GH24] . . . . . . . . . Muscles shortening at 5 constant speeds [GH24] . . . . . . . . . . . . . . Tension-length curves from the jaw muscle of the Dog-Fish [LW27] . . . . Visco-elastic muscle models [LW27] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Wilkie's quick-release machinery [Wil56] Shortening due to quick-release for various isotonic loads [W il56] . . . . . Hill's muscle model [McM84] . . . . . . . . . . . . . . . . . . . . . . . . . Musculotendon architecture [ZTS86] . . . . . . . . . . . . . . . . . . . . . Active and passive muscle models [ZTS86] . . . . . . . . . . . . . . . . . . Tendon model [ZTS86) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Approximating curves for muscle functions. . . . . . . . . . . . . . . . . . Chebyshev approximated tendon model. . . . . . . . . . . . . . . . . . . . Velocity-force function of active muscle. [ZTS86] . . . . . . . . . . . . . . . . . . . . . . . . Force-velocity function approximated with arctan. Isometric normalized muscle force vs. IMT -. .... . 32 . 33 . . 34 35 . . 36 37 . 38 . . 39 39 . . . . . . . . . . . . 40 42 43 Isometric normalized muscle force vs. 1MT _ IT. [ZT86] . . . . . . . . . . . Range camera picture from Cyberware TM 3D system . . . . . . . . . . . . . . . Point color picture . . . . . . 45 Reconstructed "Sturman" heads with 1984, 32512 and 8064 polygons . . . . 49 . . . . . . . . . . . . . . . . . . . . . . . . . . 50 2.31 Human biceps, 342 polygons Pu mp It It Up Up Pump LIST OF FIGURES LIST OF FIGURES 8 David T. Chen . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 52 53 54 55 56 57 . . . . . . . . [Bathe] . . . . . . . . 61 70 78 78 85 87 96 97 99 103 . . . . . . . . . . 106 109 111 112 114 . . . . . . . . . . . . . . . . . . . . . . . . . . 118 130 133 134 135 136 137 139 140 141 142 143 143 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.32 2.33 2.34 2.35 2.36 2.37 2.38 Frog gastrocnemius, 576 polygons . . . . . . . . . . . . Hand-derived slice through frog leg . . . . . . . . . . . MRI slice through human calf . . . . . . . . . . . . . . Reconstructed legs . . . . . . . . . . . . . . . . . . . . . Medial-gastrocnemius . . . . . . . . . . . . . . . . . . . Muscle model and muscle data after [Zaj89] and [LC87] Muscles contract with constant volume. [McM84] . . . . 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 Four node tetrahedron element . . . . . . . . . . . . . . . . . Twenty-node isoparametric brick, C numbering. adaptedfrom ... ... . .................... .... Undeformed plastic Stretched and twisted plastic . . . . . . . . . . . . . . . . . . A bent fork . . . . . . . . . . . . . . . . . . . . . . . . . . . . Structure made from two tetrahedron elements . . . . . . . . Mode shapes for twenty-node brick . . . . . . . . . . . . . . Mode shapes for Cyberware head . . . . . . . . . . . . . . . World space mesh forces for twenty-node brick . . . . . . . . Modal popup menu . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4.1 4.2 4.3 4.4 4.5 Denavit and Hartenberg link parameters [Pau81] . . . . . . . Inverse kinematically controlled skeleton motion . . . . . . . Lower limb model for minimum time kicking problem. [AD851 Muscle acting about revolute joint. [Woo76] . . . . . . . . . . Reaction constraints . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5.1 5.2 5.3 5.4 5.5 5.6 5.9 5.10 5.11 5.12 5.13 The 3d Animation/Simulation System . . . . . . . . . . . . . 3d dialog box . . . . . . . . . . . . . . . . . . . . . . . . . . . FEM mesh dialog box . . . . . . . . . . . . . . . . . . . . . . Mesh filling Cyberware head bounding box . . . . . . . . . . Mesh boundaries interactively shifted . . . . . . . . . . . . . Mesh shrunken to head . . . . . . . . . . . . . . . . . . . . . Head warped through mode-shape deformation . . . . . . . . Uniformly loaded cantilever beam. adapted from [Den Hartog] Plot of eigenvalues for 3 and 6 element beams. . . . . . . . . Deflection for 3 element beam. . . . . . . . . . . . . . . . . . Deflection for 6 element beam. . . . . . . . . . . . . . . . . . Beam made from 6 twenty-node elements, initial state . . . . Beam made from 6 twenty-node elements, final state . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6.1 6.2 6.3 .............. Model of single muscle fiber gastrocnemius . . . frog for used mesh element Finite Force generators for muscle and tendon . . . . . . . . 5.7 5.8 Pump It It Up Up 145 147 148 LIST OF FIGURES LIST OF FIGURES 9 David T. Chen 6.4 6.5 6.6 6.7 6.8 6.9 6.10 6.11 6.12 6.13 6.14 6.15 Setup for tension-length experiment . . . . . . . . . . . . . . . . . Force results from tension-length experiment. . . . . . . . . . . . . Force results from Gasser-Hill quick release experiment. . . . . . . Relaxed muscle deforms due to gravity. Active muscle pulled taut. Human gastrocnemius deformed due to gravity, then pulled taut. Volume results from tension-length experiment. . . . . . . . . . . . Volume results from quick-release experiment. . . . . . . . . . . . . Volume results from TL experiment with volume constraint. . . . . Simulation results for muscle with fiber inhomogeneities. . . . . . . Jello m otion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Scene from finished Jello animation . . . . . . . . . . . . . . . . . Blooby Puff bounce . . . . . . . . . . . . . . . . . . . . . . . . . . Up P ump It Pump It Up . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154 156 157 159 161 162 163 163 165 169 169 171 LIST OF FIGURES LIST OF FIGURES 10 David T. Chen List of Tables 3.1 3.2 Local space node coordinates for isoparametric brick . . . . . . . . . . . . . Run-time in seconds for two isoparametric interpolation implementations . 4.1 DH parameters for human left arm . . . . . . . . . . . . . . . . . . . . . . . 107 5.1 5.2 Runtime and tip deflection for 3 element beam. Runtime and tip deflection for 6 element beam. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140 141 Pump It Up LIST OF TABLES David T. Chen 11 Chapter 1 Introduction The specific goal of this thesis is to construct a biomechanical model for simulating the changes in shape that a muscle undergoes during contraction. Posed in this way, the thesis topic falls roughly into the domain of physically-based modeling for generating computer animation. The analysis of the problem is formulated using the displacement-based finite element method (FEM) from mechanical engineering. Thus, a large part of our work will involve developing and codifing techniques to apply the FEM to making animation, and in the dual case, to working out computer graphics methods that allow the effective visualization of the results of finite element simulation. Lastly, in the role of media technologist, an effort will be made to evolve computer tools that are highly integrated and interactive; that is, tools to enable one to easily design specific instances of structures to be simulated, to set simulation parameters in a straightforward way, and that accommodate quick viewing of the results that are obtained. In this light, the ultimate goal for the biomechanical muscle model becomes not only computer animation, but to have it "take on a life of its own" and become an autonomous tool for clinicians and physiologists interested in studying muscle function as well as computer animators wishing to make anatomically accurate animations Pump It Up Introduction 12 David T. Chen of muscled characters. The general problem, as stated, is to model elements of the human body through physical simulation. Modeling and animation of the human form has long been considered a significant research area in the computer graphics field. In natural communication, our bodies transmit information about ourselves and we take cues, both narrative and physical, from what is seen of others. The human shape is an important and ubiquitous expressive tool that we would like to use in computer animations. This is also a hard problem. The human body is the antithesis of shapes that is easy to model with computer graphics. The body does not have a rigid form that can be treated in the same way as "flying logos". The skeletal motions of the body are subtly complex and well coordinated. Next to the skeleton are muscles that change shape due to the complex dynamic interactions of contraction and contact. On the surface, realistic modeling of soft, living layers of skin and the ways in which it interfaces to the outside world is also daunting. Komatsu [Kom86] has put forth a minimum set of conditions for a computer graphics based human figure model, 1. The shape of the model must be smooth everywhere. 2. The three-dimensional form of the body is defined by the skeleton, which must change flexibly at the connecting angles between bones. 3. The shape must reflect the motions of the skeleton in accord with action, and the shape must always keep its smoothness. 4. A local change in the skeleton must affect only a small part of the shape. 5. Change of shape like the swelling of muscles must be expressed. To meet the goals of character animation, many people have designed systems that Pump It Up Introduction 13 David T. Chen greatly simplify the complete problem to make it possible to represent entire moving figures. Typically, the geometry is modeled to achieve the effect of how the underlying anatomy looks at the surface. The difference in this thesis is that we take a detailed look at the anatomy by modeling the important underlying structures (ie. muscles and bone), rather than stressing the ability to represent at the current time, a whole figure. The immediate goal of the thesis is to accurately model individual three-dimensional muscles. This is a "bottom up" approach, but because a physical model is created, our results can be applied both to produce realistic-looking animations of human characters and to help create new bioengineering applications in which computer graphics display is vital. As computer workstations become more powerful, and rendering and computation times drop, it will be possible to extend the results from the thesis in a straightforward way. The eventual goal then is not just character animation but to take a step towards the creation of an artificial person that can repond convincingly as its simulated muscles are activated. 1.1 Previous Work The approaches taken to computer modeling the shape of the human figure include, 1. geometric-rigidlimbs, like bones, in which only the static geometry is specified 2. kinematic-geometry of whole limb changes due to kinematic position of underlying skeleton 3. elastic-modeling parts of the body as non-linear visco-elastic-plastic composite materials that change shape due to the action of forces For the geometric case, the three methods most commonly used to represent the geometry are polygonal meshes, volume primitives and surface patches. Fetter [Fet82] used Pump It Up 1.1 Previous Work 14 David T. Chen contours derived from bioster ometric data to generate the polygons in his "Fourth Man and Woman". Human forms f -om standard volume primitives include Badler's Bubbleman [BOT79], made from spheres. or Ginsberg and Maxwell's "cloud" figure [Max83], based on ellipsoids. In these exampes, the shape of the limbs does not change as the character moves. Examples of kinematic nodels include that of Komatsu, who parameterized spline patch control points to simul;,te a contracting biceps as the elbow is bent [Kom86]. Komatsu used four major spline patch surfaces to cover the head, chest, abdomen and legs of a skeleton. Chadwick et.al. in [CHP89], generalized this approach by using a "layered" technique based on free-form deformations (FFDs) to apply muscle effects onto a skeleton. His model derives the shape f a whole limb from the kinematic skeletal state. Abstract muscles are parameterized as wo sets of FFDs. These FFDs are controlled by the skeleton position to simulate the gross effects of muscle contraction at the body's surface. A simple elastic model based on discret zed mass points joined by Hookean springs can be added on top of this to allow for autom Ltic squash and stretch of the face or whole limbs. Elastici models compriE e one form or another of displacement analysis of an elastic continuum. This analysis can be characterized as static or dynamic, linear or non-linear, isotropic or anisotropic, and s> on. The particular shape of a deformation is a function of both the internal stresses and I trains within the elastic object and the external forces applied to it. Examples of computer 1;raphics researchers modeling parts of the human body with elastic analysis include Gourre t [GMTT89], who described a system for modeling the human hand with a finite element voume meshed around bone. He formulates and solves a set of statics equations for skin defc rmation based on bone kinematics and hand/object contact points in a grasping task. WI ile bending and flexing of the hand flesh is nicely simulated, 'ie. visco-elastic-plastic models Pump It Up 1.1 Previous Work David T. Chen 15 no muscle effects or changes in the underlying shape are calculated. Pieper [Pie92], has developed a surgical simulation system that can be used both to create animation of the face and to simulate surgical reconstructions of the face. He performs a finite element analysis of the skin arranged as three different layers of material. 1.2 Elastic objects Here, single muscle masses will be modeled as visco-elastic, deformable bodies that are subjected to non-linear forces calculated from what is known about the biomechanics of the situation. The hope is that if these forces are simulated correctly, then the correct changes in the muscle shape will be automatically produced and propagated to the surface. The shape of muscle groups will be found through the constrained interaction of an ensemble of individual muscles. The technique used to define the dynamics of deformation for an elastic object is the FEM. More specifically, stiffness and mass matrices derived from finite element meshes of twenty-node brick elements will be developed to yield differential equations that control the displacement of the mesh nodal points. The resulting second-order matrix equations are decoupled using the modal technique so that dynamic simulations can be run relatively rapidly on a workstation-size computer. Because the focus of the thesis is centered around computer graphics-based applications, the geometric shape of an elastic object will be described in a standard polyhedral format that is well suited to rendering by a graphics workstations. This emphasis leads to the following particular problems that will need to be addressed in the course of the thesis work. First, is to show how a FEM mesh can be used to approximate the elastic volume defined by an input set of polyhedral geometric data. This is a discretization process. Sec- Pump It Up 1.2 Elastic objects David T. Chen I6 ond is to show how the FEM mesh is used to derive the dynamic equilibrium equations from both the shape and the material properties of the elastic volume. Third, for com2 puter graphics, is to show how the FEM mesh defines a free-form deformation that can appropriately warp the computer graphic models as the mesh changes shape in response to external forces. This can aid in visualizing the simulated deformations. Lastly, forces will be developed and applied to the FEM mesh that model muscle contraction, and other effects appropriate to computer animation such as gravity, point-to-point attachment, and collisions between objects. 1.3 Goals and Contributions To sum up, the goals and contributions of the thesis are 1. To make a 3D, dynamic, biomechanically valid model of muscle that can simulate both muscle force and muscle shape. 2. Develop techniques that will allow the finite element method to be used for making computer animation of elastically deforming objects, while not compromising its ability to approximate the dynamics of real physical structures. 3. To engineer a software testbed system that will be a useful, simple, interactive design tool for creating new simulations and animations. While the idea of using computer graphics techniques to produce animations of moving human figures is not novel, the approach taken to the problem is. The development of an accurate force based computational model to simulate muscle shape has not been attempted in the past. The desire is to make a physically realistic model of muscle and muscle function. 2 based on twenty-node brick elements Pump It Up 1.3 Goals and Contributions David T. Chen 1T Why go to all this trouble? The primary application area is making computer animation, but, if the simulation is done with a sufficient degree of accuracy, then we also have a tool that can be applied in other areas. Suppose a medical researcher wants to compute the effects of a tendon transfer surgery on a muscle's ability to generate force to drive the skeleton. He needs to have a physical model of the structures in question in order to make a clinical analysis. The model developed in the thesis should be able to make such predictions, while also providing a way for the clinician to visualize the results of a simulated procedure. 1.4 Thesis Organization The rest of the thesis is organized as follows, Chapter 2 discusses muscle anatomy and the sources of force generation within a whole muscle. Chapter 3 goes over aspects of using finite elements to simulate elastic materials. Chapter 4 concerns the complications introduced by considering the musculoskeletal system rather than isolated muscles. Chapter 5 discusses the 3d software system implemented to do the thesis work. Chapter 6 develops a forcebased finite element model of muscle that simulates both muscle force and muscle shape, and describes experiments performed using the model. Pump It Up 1.4 Thesis Organization 18 David T. Chen Chapter 2 Modeling a Single Muscle This chapter contains a quick overview of skeletal muscle anatomy and dynamics [Kel7l] [McM84] [VSL75] [CW74], presents a method from Zajac [ZTS86] [Zaj89] for computing the amount of force generated in a muscle and discusses sources of input data that will be used for defining the rest shapes of muscle masses. Skeletal muscle makes up from 40 to 45 percent of the total human body weight, so we expect that our emphasis on modeling muscle will allow us to simulate shape throughout most of the body. 2.1 Basic Muscle Anatomy Muscle connects to bone through tendons, which are bundles of connective tissue. These connective tissues are composed largely of collagen, a fibrous protein found throughout the body. The center part of the muscle can be called the "belly", which is surrounded by a connective tissue sheath called the epimysium. The tendons are actually continuations of these connective tissue sheaths that hold the muscle together. The whole muscle is held in place within the body by extensive connective tissue layers called fascia. Pump It Up Modeling a Single Muscle 19 David T. Chen Muscle Belly Figure 2.1: A whole muscle adaptedfrom [Ke171] The connective tissue also penetrates the muscle and divides it longitudinally into groups of muscle fibers known as fasciculi. It is at this level of differentiation that the muscle is supported by capillaries, veins and nerve fibers. Muscle fibers come in a wide variety of lengths-sometimes stretching the whole length of a muscle-and are usually 10 to 100 microns in diameter. The muscle fibers are composed of still smaller elements called myofibrils that run the whole length of the fiber. Each myofibril is about 1 to 2 microns thick. A single muscle fiber contains on the order of hundreds to thousands of myofibrils. It is at the level of myofibril that a discussion of the contractile mechanism for a muscle usually begins. The myofibril is made up of sarcomeres arranged in a repeating pattern along its length. This repeating pattern is responsible for the striations or banding pattern often observed on skeletal muscles. The sarcomere is the actual functional unit of contraction for the muscle. Sarcomeres are short sections-only about 1 to 2 microns longthat contract upon suitable excitation, developing tension along their longitudinal axis. The Pump It Up 2.1 Basic Muscle Anatomy 20 David T. Chen Figure 2.2: Section of muscle [Kel7l] Pump It Up 2.1 Basic Muscle Anatomy 21 David T. Chen shortening of a single muscle fiber then is due to the effect of many sarcomeres shortening in series. A bundle of muscle fibers can be thought to be many of these force generators arranged in parallel. Finally, the combined tension produced by bundles of muscle fibers is transmitted to the bones through the network of connective tissue and muscle tendons. Z membrane Relaxed myofibril Sarcomere Contracted myofibril A band Figure 2.3: The myofibril in relaxed and contracted states [Kel7l] 2.2 Muscle Force For a given muscle, the arrangement of muscle fibers relative to its tendon attachments will determine the amount of shortening during contraction and thus the amount of force generated. In general, there are two different kinds of fiber arrangements, longitudinal and penniform. The fibers in a longitudinal muscle run parallel to each other along the entire length of the muscle. In a penniform muscle the fibers terminate at an angle relative to the tendon. There are several variations of penniform muscles. Unipennate muscles have their fibers arranged obliquely to a tendon only on one side. In a bipennate configuration, the fibers converge onto the tendon from both sides. Multipennate muscles are a combination of both unipennate and bipennate fiber arrangements. Pump It Up 2.2 Muscle Force 22 David T. Chen Figure 2.4: Longitudinal muscles [Kel7l] Unipennote Bipennate Figure 2.5: Peniform muscles [Kel7l] Pump It Up 2.2 Muscle Force 23 David T. Chen When the fibers of a longitudinal muscle shorten by an amount F,, the muscle as a whole shortens an amount M, = F,. For a penniform muscle, the amount of muscle shortening depends on F, and the pennation angle a. From Figure 2.6 it is clear that M, = F, cos a. This relationship also shows that the penniform fiber arrangement approaches the longitudinal as a approaches zero. 7A- Ms mimmuminiiniinuuum MS- Figure 2.6: Comparison of longitudinal and penniform shortening. McO, is the length after contraction. adaptedfrom [Kel7l] The amount of force developed by a shortening muscle depends on, among many factors, the number of contracting muscle fibers, the size of each fiber and the internal fiber arrangement. The product of the number of fibers and the fiber size is itself an important measure and is called the physiological cross section, which, for a longitudinal muscle, can be determined by making a transverse cut through the belly of the muscle. For a pennate muscle, the results of such a cut would depend on the length of the muscle and a. From Figure 2.7 it can be seen that the area defined by a cut at X determines the physiological cross section for the muscle on the left, but would not include all the fibers Pump It Up 2.2 Muscle Force 24 David T. Chen for the unipennate muscle on the right. To determine the cross section for the unipennate muscle requires summing the area from cuts at A, B and C. C B A Figure 2.7: Physiological cross section adapted from [Kel7l] In general then, a penniform fiber arrangement trades off a lesser amount of muscle shortening for a greater number of fibers that can be involved in contraction. But pennation angle effects the final force that a muscle can develop in yet another way. Figure 2.6 also shows that if a muscle fiber generates a force in the direction of F, the amount of force produced along the muscle's line of action must again be scaled by cos a. 2.2.1 Sliding Filament Theory of Contraction The discussion above has concerned the more or less macroscopic properties of muscle force generation. Here we will briefly touch upon the contractile mechanism within a single sarcomere. Muscles have been differentiated into at least eight separate protein structures, of which four play a role in contraction. The two most important of these are actin and myosin. Pump It Up 2.2 Muscle Force 25 David T. Chen These two contractile proteins form filaments within the sarcomere, and, when viewed in cross section, can be seen to be packed hexagonally with six thin filaments surrounding each thick filament. The thick myofilaments are made of myosin, the thin myofilaments are made of actin. Z line H zone I band A band Z line sarcomere thin myofilament thick myofilament Figure 2.8: Electron micrograph showing three myofibrils in a single muscle fiber [VSL75] The idea behind the sliding filament theory of muscle contraction is that as a muscle fiber shortens, the thin and thick myofilaments do not themselves get shorter, rather they slide across each other. This idea was presented concurrently in the same issue of Nature by A. F. Huxley and H. E. Huxley in 1954 [HN54] [HH54]. A. F. Huxley developed an Pump It Up 2.2 Muscle Force 26 David T. Chen interference microscope that allowed him to watch changes in the banding pattern of isolated frog muscle fibers under various circumstances. As the fiber was subjected to a purely passive stretch or shortening, the I-bands became either longer or shorter, but the length of the A-bands remained about the same. Under an isometric contraction with both fiber ends fixed, the banding was essentially invariant. Under isotonic contraction, it was again the I-bands that took up the resulting change in length. Because it was known at the time from electron microscope studies by H. E. Huxley that the A-bands were defined by birefringent rodlets of myosin and that the thin actin myofilaments extended through the I-bands into the A-bands, A. F. Huxley was able to conclude that during a muscle fiber contraction, the actin filaments were drawn into the A-bands, between the myosin rods. Furthermore, he proposed that the known dependence of the isometric tension produced in a muscle fiber to the fiber length is caused by the change in overlap between actin and myosin within a sarcomere. Z line thin myofilament H zone I band A band Z line thick myofilament Figure 2.9: Changes in fiber banding pattern due to contraction [VSL75] Pump It Up 2.2 Muscle Force 27 David T. Chen 2.2.2 Hill's Force Model One of the simplest kinds of experiments that can be done to a prepared, isolated whole muscle is to measure the force output as the muscle is stretched through a number of constant lengths. If this is done with no stimulation, then the resulting plot of force or tension to length is said to represent the passive elastic properties of the muscle. This passive tension-length curve has an exponential shape in which the curve gets steeper and steeper the more the muscle is elongated. This behavior is very similar to a rubber band in which the material can be pulled very easily until it is all "stretched out", and then the rubber band can feel very stiff. If the same kind of tension-length plot is then made with the muscle fully stimulated, then a different curve is produced that has components from both active and passive force components. This curve, of course, should always be greater than the passive force-length plot by itself and is called the total tension-length curve. Finally, the tension-length curve that represents only the active muscle force is found by subtracting the passive curve from the total curve as in Figure 2.10. The length dependence of the developed force is wholly consistent with the sliding filament theory of muscle contraction. Futhermore, from measurements on human subjects, A. V. Hill proposed that there is also a velocity dependent force component that counteracts the contraction force. That is, the force exerted by the muscle decreases as the speed of shortening increases [GH24]. It was thought at first that this phenomenon depended on an automatic regulatory mechanism within the central nervous system, but Gasser and Hill showed through quick-release experiments on isolated frog muscle that this damping effect was part of the "fundamental character" of the muscle itself. Two experiments point out this result. First, a muscle held isometrically was suddenly allowed to shorten to a new length against no applied load. The force that was recorded fell below the amount that corre- Pump It Up 2.2 Muscle Force David T. Chen 28 Figure 2.10: Tension-length curves. The dotted line shows the length-tension curve of the resting muscle. The total force recorded on tetanizing the muscle is shown by the solid line. The extra force developed on stimulation is shown by the dashed line. The progression from (a) to (c) results from muscles with progressively less connective tissue. [CW74] Pump It Up 2.2 Muscle Force 29 David T. Chen sponded to the isometric equilibrium point of the new length and only slowly developed tension back up to that point. The apparatus to perform this experiment is shown in Figure 2.11 where the knot at K determines the final amount of shortening. Schematic versions of the curves obtained from their quick-release experiment are shown in Figure 2.12. ADASTABLE JAW K MUSCLE LEVER S Figure 2.11: Gasser and Hill quick-release apparatus [GH24] The observation that the measured muscle force did not instantaneously reach the level predicted by the new length indicated a damping effect within the contractile machinery. In the second experiment, a muscle was allowed to shorten at constant velocities, and a series of plots were made of the force required to produce that speed and the amount of shortening that was finally experienced. The area under these tension-shortening curves was then integrated to yield a relationship between work (force * distance) and velocity. The work-velocity curve has a decreasing slope, which is also consistent with the idea of a Pump It Up 2.2 Muscle Force 30 David T. Chen ARM 7- j- _ _ _ Ile o06 0 >O TIME -001 sEcs 8 0 CK30 Figure 2.12: Quick-release curves, plotting tension versus time [GH24] velocity-dependent force within the muscle. These curves are illustrated in Figure 2.13. RELATIVE SPEED OF SHORTENING At A2 A3 1-47 4-5 5-1 Figure 2.13: Muscles shortening at 5 constant speeds [GH24] Quick-release experiments also play a role in determining the so-called series elastic element of a muscle. The series elastic component was originally proposed by Levin and Wyman in [LW27]. They built a device that allowed them to alternately stretch and release a muscle stimulated at a short rest length such that the passive parallel component does not enter the picture. The tension-length curves they obtained from trials at different speeds on the jaw muscle of a Dog-Fish is shown in Figure 2.14. Pump It Up 2.2 Muscle Force 31 David T. Chen A TENS/ON S 6 7 g 9 \DOGFISH c M I C''I I B / I 234 Figure 2.14: Tension-length curves from the jaw muscle of the Dog-Fish [LW27] The fastest release is the curve on the far left, the quickest stretch is on the far right. If there were no series elastic component, the Dog-Fish plots would not have the exponential shape that is observed, rather, the lines of stretch and release would be straight. Levin and Wyman proposed the visco-elastic muscle model II on the right in Figure 2.15 to explain their findings. Their model is an extension of Hill's original visco-elastic model (I in the same figure) that included only the damping effects deduced from his measurements of the relationship between force and velocity. Wilkie in [Wil56] made very direct measurements of the series elastic component with a quick-release type experiment. A schematic of his device is shown in Figure 2.16. The muscle is stimulated and develops force isometrically, stretching out its series elastic component. On release by the electromagnet at (e), the muscle is subjected to an isotonic load defined by the weight at (c). The stop at (d) insures that the load is applied only after release. The damping system at (f) removes mechanical vibrations in the lever system that would otherwise upset the muscle length measurements. Wilkie found that immediately after the release, the previously stretched series elastic Pump It Up 2.2 Muscle Force 32 David T. Chen Figure 2.15: Visco-elastic muscle models [LW27] e Figure 2.16: Wilkie's quick-release machinery [Wil56] Pump It Up 2.2 Muscle Force 33 David T. Chen element shortens very rapidly to a length consistent with the isotonic load that is used. Then the contractile component shortens with a much lower velocity corresponding to the load. These two phases of shortening are shown in Figure 2.17. The initial perpendicular drop of length provides direct evidence for an elastic component in series with the contractile machinery of the muscle. 2mm SO/Sec g wt. Figure 2.17: Shortening due to quick-release for various isotonic loads [Wil56] A simple mechanical model of muscle that takes into account the effects described above is shown in Figure 2.18. This model is commonly attributed to A. V. Hill. The active state force To is found, as discussed above, by subtracting the total force measured at different lengths for a stimulated muscle from that found to be due to passive effects alone. The notation To(x1, t) indicates that this force is a function of the muscle length and time-varying activation. The passive parallel stiffness KPE has contributions due to the penetration of connective tissue through the muscle body resulting in the fasciculus Pump It Up 2.2 Muscle Force 34 David T. Chen divisions and also interfiber elasticity. The parallel damping component B is most likely due to the rate of the biochemical reactions that are responsible for contraction at the myofilament level. The series stiffness KSE is primarily from the effect of tendon at the muscle attachment points, but is also probably partially due to the details of myofilament attachment within a sarcomere. The series element is very important in its ability to buffer the rapid change from inactive to active state and also provides a mechanical energy storage mechanism for the body in motion. Controctile component T T KSE KPE Sx, - - x2 x Figure 2.18: Hill's muscle model [McM84] The Hill model while very simple, has proven enormously useful in practice in making calculations of the force generation of muscles working against different kinds of loads. 2.2.3 Zajac's Force Model Zajac [ZTS86] [Zaj89] has developed a "dimensionless" lumped model of a complete musculotendon actuator that can be easily scaled to model particular whole muscles. Zajac's model is a refinement of the Hill model, and the normalized force curves that are presented directly reflect the non-linearities that result from the action of sliding filaments. The curves Pump It Up 2.2 Muscle Force 35 David T. Chen for the active and passive muscle force components are taken from measurements of single muscle fibers to ensure that tendon effects are not superimposed. Furthermore, pennation effects are directly included, while the series elastic element not associated with tendon is removed. The isometric force generated in a particular actuator depends on one set of parameters that is considered constant over all actuators and another set that is musculotendon specific. The four specific parameters are, pennation angle a FO maximum isometric force of active muscle lM optimal muscle length at which FO is developed lT tendon rest length Tendon Tendon LT lu Figure 2.19: Musculotendon architecture [ZTS86] The active muscle is represented in Figure 2.19 by the contractile element CE. Force Pump It Up 2.2 Muscle Force 36 David T. Chen developed by passive muscle is from kPE and is summed with the force from CE. The effect of the series elastic element kSE is lumped with the tendon model kT. The dimensional units of interest are force and length. F0 and i" are the normalizing factors for these units. A tilde above a symbol denotes that it is a normalized quantity, for example, normalized muscle fiber length m Other quantities and relationships used are, iMT musculotendon length IT tendon length IMT _IT + lM cos a Zajac gives the non-specific, dimensionless functions to model a musculotendon actuator in Figure 2.20 and Figure 2.21. FORCE kw 1.1 ___ 1.0 - - active force f4(jM) passiwv force )FPE(iAU) -. - - - - - - 0.E LENGTH jTm Figure 2.20: Active and passive muscle models. Normalized active muscle force FCE(1M) and passive force PPE(M) vs. normalized muscle fiber length IM. [ZTS86] Pump It Up 2.2 Muscle Force 37 David T. Chen FORCE ?' Slop. = 3,S APs 1.0 Lia 0.5 - - - - - flegi.. - To. Region 0.0 q 0.04 0.03 0.00 STRAIN .r Figure 2.21: Tendon model. Normalized tendon force FT(JT) vs. tendon strain eT. [ZTS86] The isometric muscle force functions can be written, Fio(IM t) - PM(iM, t, a) PCE( M = t) + PPE(TM)) cos a (T(, where a(t) is the time-varying normalized muscle activation function. For tendon, the normalized force is PT(eT) where eT is the tendon strain defined by, iT _ l-Tlcos )- _ (lMTfMo IT ~~ To use Zajac's muscle model, the functions FfE(M), Cs i 11. a)-1T FPE(M) and PT(ET) and their derivatives need to be approximated. The active muscle function FCE(iM) is implemented as an interpolating cubic spline through twelve control points from Delp [De190]. derivative function dpCE -/- The is simply the derivative of the interpolating spline. The passive parallel force FPE(lM) is estimated with the quadratic function, PPE(M) = 4 (M dFPE dl M Pump It Up 1)2 if TM > 1 else 0 if M> 1 else 0 2.2 Muscle Force 38 David T. Chen Plots of these two approximating functions are presented in Figure 2.22 for comparison with Zajac's curves. The tendon model F(eT), is implemented as an order 50 Chebyshev Figure 2.22: Solid line is spline approximated active force function. Dashed line is quadratically approximated passive component. polynomial. Evaluating and finding the derivatives of such polynomial functions is very straightforward [PFTV88]. The shape of the Chebyshev approximated tendon force is plotted in Figure 2.23. To characterize the dynamic properties of a musculotendon actuator, it is also necessary to consider the velocity dependent nature of the muscle forces. These damping forces are represented by the dashpot element B in Hill's model of the previous section. Zajac depicts the velocity-force relationship as in Figure 2.24 with the dimensionless form of the velocity ~CE. This muscle velocity is normalized with respect to the fiber rest length laM and the maximum normalized velocity iBCE, which is a fifth parameter specific to modeling the dynamics of a particular muscle. For our purposes, it is necessary to find force as a function of velocity, rather than Pump It Up 2.2 Muscle Force 39 David T. Chen Figure 2.23: Chebyshev approximated tendon model. vELOwrY - ;," FORCE ?CfEI| Figure 2.24: Velocity-force function of active muscle. Dimensionless velocity obCE vs amount of normalized force relative to isometric force. [ZTS86] Pump It Up 2.2 Muscle Force 40 David T. Chen the velocity as a function of force, as in [AD85]. Thus, Zajac's curve is turned on its side and approximated with, f(jCE) _ 1.65 arctan(3.1 * (~,bE + .32774)) - arctan(3.1 * .32774) + 1 which is plotted in Figure 2.25. Negative velocity is for muscle contraction, while lengthening muscle will have positive velocity. The constants are set so that the normalized force will be 1 when the velocity is 0, the force will be 0 when the velocity is -1, and the asymptotes are as in Figure 2.24. Figure 2.25: Force-velocity function approximated with arctan. Finally, in the dynamic case, the total active force from the contractile element is seen to be a function of the activation a(t), the force function FCE(IM),and the normalized muscle velocity ~,CE pCE Pump It Up _ f3CE (M _ ~CE)a(t) CE (M 2.2 Muscle Force 41 David T. Chen and the force in the whole muscle is PM = ( PCE + pPE([M)) cosa As an example application of Zajac's model, lets calculate the maximum force that can be generated by an isometric musculotendon actuator in steady state. First, observe for this case that the force in the tendon should equal the force in the muscle and that velocity effects will not come into play, so #T(e) and writing the tendon strain in terms of FT ( -MT - PM(l M ) = 0 IM, (M)= G(IM ) - Mls) Thus, to find the isometric muscle force, it is necessary only to find the zeros of G(M). This is easily done using a one-dimensional root finder like Newton-Raphson [PFTV88] as long as G(IM) and the derivative G'(IM) can be evaluated for arbitrary normalized muscle lengths IM. Writing for G'(I), , = dT deT dET diM d(io+ diM dFPE cs diM And finally in terms of the dimensionless, consistent functions as implemented in Figure 2.22 and Figure 2.23 G(I M ) G'(IM) FT = dFt)2S (\ + -o -f (a(t)PCE(M - dim± + d-P dim) ± PPE(M) Cosa o To illustrate the effect of the tendon slack length on the behavior of Zajac's model, the zeros of G(IM) were calculated as above for varying values of IT. Plots are presented Pump It Up 2.2 Muscle Force 42 David T. Chen of normalized muscle force versus length for these different values of tendon rest length in Figure 2.26. The good correspondence between the curves of this figure and the ones presented in [ZTS86) (see Figure 2.27), we use as validation for our implementation. Figure 2.26: Isometric normalized muscle force vs. IMT - lI. line is 1T = 8, and dotted line is l' = 16. 2.3 Solid line is IT = 1 dashed Muscle Shape This thesis will test the hypothesis that to make a good simulation of the changes in shape that a contracting muscle experiences, it is sufficient to characterize both the resting material and the changes in force known to be important to the contractile process. The primary benefit of this approach is that if the forces are calculated properly, then not only will it be possible to visualize a muscle in action, but that a valid biomechanical model will also be developed that can be used in further experimentation. For the purposes of visualization, however, it is important to obtain accurate geometric representations of the Pump It Up 2.3 Muscle Shape 43 David T. Chen FORCE Vr 1.5r- LENGTH tur- t7 Figure 2.27: Isometric normalized muscle force vs. IMT - IT. [ZTS86] rest shapes of muscle masses upon which the dynamic simulation techniques developed in the next chapter will be run. The emphasis of the thesis is on dynamics and not geometric modeling, so this section will serve only to point to sources from which input data has been obtained. Because the interest here is primarily in computer graphics based applications, the goal in this section is to construct polygonal models that can be easily treated with standard rendering and animation routines. It will be shown in Section 3.2 how a free-form deformation based on twenty-node isoparametric cubes can be developed to govern both the dynamics formulation and the visualization process by defining a space that controls how the points of these polygonal models can be warped as the simulation demands that objects change shape. It will also be shown in Section 5.6 how these polygonal models will be used to define the initial geometries for finite element meshes made from isoparametric cubes. Geometric models that have served the purposes of the dynamic simulation programs Pump It Up 2.3 Muscle Shape 44 David T. Chen have been prepared from a variety of sources. The first experiments were made with range data of human heads from a Cyberware TM 3D digitizing system. Muscle rest shapes were constructed from both the Swivel 3DTM Professional [MhLH90] modeling program on the Macintosh and from contour stacks derived from magnetic resonance imaging (MRI) systems. 2.3.1 Range Camera Data Range data such as that from the Cyberware camera is very simple to transform into a polyhedral representation. Two output files are produced by the scanning system. The first is an 8-bit range picture that represents a cylindrical arrangement of points from the source object, the second is a 24-bit image picture that can be used to texture-map color information back onto the scanned geometry. Two such data files from a human head' are shown in Figure 2.28 and Figure 2.29. The Cartesian x, y location for each pixel in the range picture encodes the cylindrical 0 and z coordinates for each sampled point, while the grayscale pixel value at each location is the radius r for that 0 and z. The image picture is the RGB color value at each of these digitized points. The cylindrical samples are simply transformed into 3' by x = r cos9; y = r sin 0; z=z To convert range data into polyhedral form, the total number of points and polygons is printed, a point list is made from the range picture, and then connectivity information for each (quadrilateral) polygon is written out. This we call an OSU file after the polyhedral data standard created at Ohio State University. Finally, a subsidiary vertex color file is made from the 24-bit image picture. This is illustrated by a simple C language program, 'Thanks to David Sturman for the use of his head Pump It Up 2.3 Muscle Shape David T. Chen 45 Figure 2.28: Range camera picture from Cyberware TM 3D system Figure 2.29: Point color picture Pump Pump It It Up Up 2.3 Muscle Shape 2.3 Muscle Shape 46 David T. Chen range2osu, that makes an OSU file from range data. #include <stdio.h> #include <math.h> #define PI (3.14159265359) typedef unsigned char byte; typedef byte PIXEL[3]; range2osu( range, color, width, height, gamma, osufp, vclfp ) 10 byte *range; PIXEL * color; int width, height; double gamma; FILE *osufp, *vclfp; { int no-pts, no-polys; no-pts = height * width; no-polys = (height-1) * width; 20 fprintf(osufp, "Xd %d\n", no-pts, no-polys); range2pts( range, width, height, osufp ); range2quads( range, width, height, osufp ); range2vcl( color, width, height, gamma, vclfp fflush(osufp); fflush(vclfp); ); } To generate the point list, range2pts first finds 6, z and r corresponding to pixel i, j. The space is arranged so that 6 begins at 90* and increments positively in a full circle, r is in the range [0,1] and z is [-1,1] where +z is up. The result is then transformed into R' and printed. range2pts( range, width, height, osufp ) byte *range; int width, height; FILE *osufp; { int i, j; double x, y, z, r, theta, thetainc; thetainc = 2 * PI / (double)width; for (i=0; i<height; i++) { z = (-2. / (double)(height - 1) * i) + 1.; 10 /* Find z from current row indx */ for (j=O, theta = PI/2.; j<width; j++, theta += thetainc) Up Pu mp ItIt Up Pump 2.3 Muscle Shape 2.3 Muscle Shape 4T David T. Chen { r = ((double)(range[i*width + j])) / 255.; /* Find r from grayscale*/ x = r * cos(theta); y = r * sin(theta); fprintf(osufp, "%g Xg %g\n",(float)x, (float)y, (float)z); } } } 20 Polygons for the OSU file are tessellated into quadrilaterals by range2quads. The polygons are arranged along rows of points where the last polygon in each row is made to wrap around and join with the points from the first polygon in that row. This prevents any shading seams from the renderer. range2quads( width, height, osufp ) int width, height; FILE *osufp; { int i, j, k; for (i=O; i<height-1; i++) { k = i*width; for (j=O; j<width-1; j++) { k++; fprintf(osufp, "4 %d %d %d %d\n",k, k+1, k+width+1, k+width); } k++; 10 fprintf(osufp, "4 %d %d %d %d\n",k, i*width+1, (i+1)*width + 1, k+width); } The vertex color file is made from the 24-bit image picture associated with the range picture. Gamma control is given to set the contrast of the output vertex colors. range2vcl( color, width, height, gamma, vclfp ) PIXEL *color; int width, height; double gamma; FILE *vclfp; { int i, j; double r, g, b; 10 for (i=O; i<height; i++) { for (j=O; j<width; j++) { r = ((double)(color[i*width + j][0])) / 255.; g = ((double)(color[i*width + j][1])) / 255.; b = ((double)(color[i*width + j][2])) / 255.; It Up Pu mp It Up Pump 2.3 Muscle Shape 2.3 Muscle Shape 48 David T. Chen gamma = 1./gamma; r = pow(r, gamma); g = pow(g, gamma); b = pow(b, gamma); r = clamp(r, 0., 1.); g = clamp(g, 0., 1.); b = clamp(b, 0., 1.); 20 fprintf(vclfp, "Xg Xg %g\n",(float)r, (float)g, (float)b); } } Typically, the data sets acquired from the Cyberware process are quite large, making full resolution models unwieldy. For example, a 512x256 size range picture will generate an OSU file with over 130,000 polygons. To make lower resolution, more conveniently sized geometric models, a downsampling operation is first performed to the range and color images, then OSU files are made using the range2osu program on the resulting smaller pictures. Downsampling in the image-space is much simpler than trying to do the equivalent filtering in world-space in order to make models with fewer polygons. It should be noted that with appropriate filtering, very nice lo-res geometric models can be achieved. In fact, for this kind of data many 2D paint and filtering operations have been found to be very effective [Wil90]. The Adobe PhotoshopTM paint program on the Macintosh has proven invaluable in performing the operations mentioned above, as well as allowing interactive repair of noisy range data. 2.3.2 Manual Shape Input Not surprisingly, often the easiest way to make a computer graphics object is to use an interactive program such as Swivel 3 DTM Professional that can create 3D geometries through extrusion, lathing, and skinning operations 2 . The first muscle object that was created in the course of the thesis work was a human biceps from an anatomically accurate plastic model. Points were digitized from the plastic model for both TOP and SIDE views. The biceps was then "lathed" using a circular cross section. The resulting computer graphics 2 Thanks to Steve Drucker for writing the program to convert Swivel output files into OSU format Pump It Up 2.3 Muscle Shape 49 David T. Chen Figure 2.30: Reconstructed "Sturman" heads with 1984, 32512 and 8064 polygons model is shown in Figure 2.31. Since much of the experimental work involving muscle biomechanics is done using frog muscles, the gastrocnemius muscle from a prepared frog was digitized for use in the computer simulated biomechanical experiments discussed in Section 6.1. Some time was spent observing Dr. Simon Gitzer at MIT in the "frog lab" making force-length measurements from the gastrocnemins of an actual animal. After these were done, the muscle was fully dissected and measured for input into Swivel. The procedure used was much like that for the plastic biceps, and a lathed object was created. This is shown in Figure 2.32. Pump It Up 2.3 Muscle Shape 50 David T. Chen Figure 2.31: Human biceps, 342 polygons 2.3.3 Contour Data Imaging from CAT and MRI scanning systems is a relatively new but very important source of clinical data. These systems acquire three-dimensional objects as a series of 2D slices arranged along an axis in space. The "skinning" facility in Swivel can be used to operate on data sets of this kind, where anatomical forms are defined by varying the shape of the cross section along the length of the body. More sophisticated techniques such as the marching cubes algorithm [LC87] can automatically create polygonal models of constant density surfaces from 3D data arrays of this type. One of the practical drawbacks of CAT and MRI systems is that they are very expensive and so access to them is limited. For this reason, an effort was made by Dr. Gitzer to reconstruct a set of frog musculature by, in essence, making the stack of contour informa- Pump It Up 2.3 Muscle Shape David T. Chen 51 Figure 2.32: Frog gastrocnemius, 576 polygons tion by hand. A frog leg was embedded in epoxy and sliced into two-dimensional sections. Slides were made of these sections and enlargements made for digitization as a precursor to making a 3D model. The slides were scanned into the computer and the individual muscles differentiated by flood-filling their regions with different grayscale values. Figure 2.33 shows one such slice. The idea behind trying to digitize the frog musculature as described is to obtain data for a whole musculoskeletal system, with the muscles and bones in their correct relative in vivo positions. Many interesting problems are introduced by considering the whole system. Forces must be calculated for modeling contact between bone, muscles and skin. A simulated skeleton can be driven by muscle forces calculated at the tendon attachment points. Higher-level coordination and reflexes can be modeled. Chapter 4 will touch upon some of these topics. Purnp It Up 2.3 Muscle Shape az David T. Chen Figure 2.33: Hand-derived slice through frog leg The effort with the frog leg was subsequently put on hold when a polygonal data set from an entire human left calf became available through Dr. Alan Garfinkel at UCLA. The source for the calf model was a long sequence of MRI scans, that were carefully hand segmented into the individual, anatomical muscle masses and then "skinned" into triangles. Ten muscles, including the medial-gastrocnemius, the lateral-gastrocnemius, and the soleus, and one muscle group make up the data. The tibia and fibula bones are also included. Figure 2.34, from Dr. Garfinkel shows how the MRI scans were anatomically carved up. The image is shown with its colormap inverted for clarity. Because the leg data was received as files of triangle meshes, no further processing had to be done to ready them for simulation or display. Figure 2.35 shows three different views of the reconstructed leg. The entire data set is shown in the middle view. In the left view, the overlying gastrocnemius muscles and the soleus are removed to show the underlying Pump It Up 2.3 Muscle Shape 1s David T. Chen Figure 2.34: MRI slice through human calf 2.3 Muscle Shape Up Pump ItIt Up Pump 2.3 Muscle Shape David T. Chen 54 structures, and the tibia and fibula are shown on the right. Figure 2.35: Reconstructed legs The experiments done in Section 6.1.4 using this data will be centered around the medial-gastrocnemius. This muscle was chosen both because of its large size, and because it is on the outside, closest to the skin. Thus it should play a large part in determining the shape of the whole leg. Figure 2.36 shows three views of the medial-gastrocnemius. 2.4 Simulating a Muscle This section has discussed two different aspects of muscle that are essential to making a simulation -the first topic was muscle models, the second concerned the acquisition of muscle data. We have shown how the Hill model was developed and discussed how Zajac's model is a refinement. We have also described an implementation of the Zajac model. Our Pump It Up 2.4 Simulating a Muscle 55 David T. Chen Figure 2.36: Medial-gastrocnemius data sources are Cyberware scans, hand-made slices, MRI slices and direct geometric output from Swivel. All these are turned into a standard polyhedral representation for display. To simulate the action of muscle for a computer graphics application, the model and data must be synthesized, and for this the finite element method is used (see Figure 2.37). The FEM will be the vehicle for our muscle model. The polyhedral data is used to define meshes of finite elements. Dynamic equilibrium equations are derived from the mesh. Zajac's model is used to apply forces to the mesh node points. The FEM model will then be dynamically simulated forwards and the mesh will automatically deform in response. A free-form deformation defined by the mesh will help us visualize the resulting changes in shape due to the contraction. There are many things known about muscle that a computationally based muscle should be able to predict. For the model to be interesting biomechanically, we should be Pump It Up 2.4 Simulating a Muscle 56 David T. Chen Muscle Model Figure 2.37: Muscle model and muscle data after [Zaj89] and [LC87] able to the calculate the timevarying course of the force that a muscle generates at different lengths, and with different tendon rest lengths. The model should also be able to predict the effect of velocity dependent forces. Thus, as a way of validating the final implementation, an effort will be made to reproduce some of the experiments on whole muscle that lead to the development of Hill's biomechanical model. Besides generating force to move the bones, a 3D model of muscle should conserve volume as its shape changes. Because of the enclosing tendon sheath, muscle preserves its volume as it elongates and contracts. In fact, one of the earliest recorded experiments performed on a single prepared muscle demonstrated this effect [McM84]. Jan Swammerdam performed the experiment illustrated in Figure 2.38 on a muscle removed from a frog in the early 1600's. Later, the constant volume finding was extended to human muscles by Glisson who had subjects place their arms in a water filled tube sealed at the elbow. Pump It Up 2.4 Simulating a Muscle David T. Chen 57 The experiment of Jan Swammerdam, circa 1663, showing that a muscle does not increase in volume as it contracts. A frog's muscle (b) is placed in an air-filled tube closed at the bottom (a). When the fine wire (c) is pulled, the nerve is pinched against the support (d), causing the muscle to contract. The drop of water in the capillary tube (e) does not move up when the muscle contracts. From Needham (1971). Figure 2.38: Muscles contract with constant volume. [McM84] Pump It Up 2.4 Simulating a Muscle David T. Chen 58 Chapter 3 The Finite Element Method The displacement based finite element method (FEM) has been widely used to model elastic, deformable materials in engineering analysis. It is particularly well suited to a computer implementation and can be used effectively to model real world physical situations with real world boundary conditions and forces. For the purposes of simulating a muscle, the approach will be to formulate the dynamics of a volume preserving elastic object with material properties to be found in the literature. The rest shape for a muscle will be determined from either hand derived or machine scanned histological data. The important input forces will come from Zajac's biomechanical model discussed in the previous section. When considering a musculoskeletal system, other forces need also be considered. These include forces from the fascia sheath drawing the muscle to the bone and muscle-bone and muscle-muscle contact. To complete the thesis project, a system that performs FEM dynamics on an HP graphics workstation based on the modal formulation has been implemented. The rest of this chapter will discuss the finite element foundations for the resulting computer program and point out the tradeoffs that are made to make solving the dynamics of deformation Pump It Up The Finite Element Method David T. Chen 59 tractable for this hardware platform. For computer animation, the steps taken to perform dynamic simulations of elastic objects using the finite element are, 1. Begin with polyhedral model 2. Interactively specify FEM mesh 3. Solve for equilibrium equations, do modal transformation, etc. 4. Simulate dynamics by calculating forces and finding mesh displacements 5. Warp points of polyhedral model into deformed mesh space 6. Render new shape The polyhedral model represents the shape of the elastic body to be simulated and is considered the input data. A FEM mesh is constructed that approximates the volume of the data with some number of finite elements. From the FEM mesh and the material properties of the object under investigation, dynamic equilibrium equations are found, the modal transformation is performed, and other preprocessing steps are taken. A standard numerical differential equation solver is then used to advance the state of the mesh one time step forwards. This results in displacements for the nodal points of the FEM mesh that are then used to warp the points of the original polyhedral model with a free-form deformation technique. The new shape is then rendered and the next simulation step taken. While steps 1-3 are considered part of a preprocessing procedure, steps 4-6 happen over and over throughout an interactive simulation application and is called the simulation loop. Much of the discussion to follow concerning the finite element method is from Bathe [Bat82] and is presented here as a way of introducing the FEM to computer graphics researchers. Because one of our goals is to use the FEM within interactive graphics applica- Pump It Up The Finite Element Method David T. Chen 60 tions, it was decided to implement a custom finite element package that could be tightly coupled to graphics output, rather than using a commercially available system. An emphasis carried throughout our implementation is to speed up the steps of the simulation loop whenever possible. One of the key technical contributions of the thesis is to define the free-form deformation of step 5 that "links" the FEM with computer graphics output, in Section 3.2.2. 3.1 Equilibrium Equations To model the elastic properties of deformable objects, sets of differential equations can be defined that govern the dynamics of their deformation. There are a variety of techniques for deriving these equations-Terzopolis and Fleisher discuss in [TF88] a method based on an analysis of the energy of deformation for an elastic material, while Pentland and Williams in [PW89] discuss the method of finite elements. This thesis models elastic objects as collections of twenty-node isoparametric brick elements. For a body having n nodal points, the finite element equations have the form Mi +Cit+ Ku = R Where u is an 3n vector of nodal displacements, M, C and K are 3n x 3n matrices describing the mass, damping and stiffness between points within the body, and R is a 3n vector of forces applied to each node. 3.1.1 Stiffness Matrix K The stiffness matrix K can be found by choosing a specific interpolating function for displacement throughout the body and using a linear approximation for elasticity. Though twenty-node isoparametric elements will be used in the subsequent muscle analysis, the Pump It Up 3.1 Equilibrium Equations 61 David T. Chen discussion that follows is based on a four-node tetrahedron element for simplicity. It will be shown how the stiffness matrix for a twenty-node element can be found in a similar way. Following a development for linear planar elements from [Roc83], K is derived for the special case of the tetrahedral finite element in Figure 3.1 as follows. .3 Figure 3.1: Four node tetrahedron element { At each of the four nodes of the tetrahedron, define a three-vector for the displacement, {U} and for the force. {F} = Pump It Up 3.1 Equilibrium Equations David T. Chen The tetrahedron has three displacement degrees of freedom for each of the four nodes, for a total of twelve DOFs. For the tetrahedral element these are, {U} I { U0 Ul,, 2 U3 =T {O }( V0 W0 U0 V1 W T T and the nodal forces acting on the element are written, {F*} = oF F1 F22 FAIF 3 = F0 F' Fx1 z Fy, Fzj- Now, choose a displacement function f(x, y, z) that defines the displacement U(x, y, z) at any point in the element. For the tetrahedron it is natural to choose the linear functions, u(x, y, z) = ai + a 2 x a 3y + a 4z v(x, y, z) = a 5 + a6 X + a7 y + a8 z w(x, y, z) = as + + aiox + a1 1 y + a1 2 z So the internal displacement is, U(x, y,z) {U(x, y, Z)} = v(x, yz) F w(x, y, z) al 0 a2 0 a3 z C12 or more compactly, {U(x, y, z)} = [f(x, y, z)]{a} Pump It Up (3.1) 3.1 Equilibrium Equations David T. Chen The next step is to express the state of displacement U(x, y, z) within the element in terms of the nodal displacements {Ue}. Looking at node 1, {U 1 } = {U(Xi,y1, zi)} = [f(Xi, y1, zi)]{a} or, {a} {U 1 } = For the whole element, [f(Xo1 YO, zo)] {Uo} {Ue} = [f(Xi, y1, zi)] {U1} {a} = [A]{a} [f(x 2 ,Y2, z 2 )] {U 2 } {U 3 } Finally, solving for the vector a, (3.2) {a} = [A]~1{Ue} And substituting for {a} in Equation 3.1 {U(x, y, z)} = [f(x, y, z)][A]-l{Ue} = [H]{Ue} Now, lets relate the strains {e(x, y, z)} at any point within the tetrahedral element to the displacements {U(x, y, z)}, and hence to the nodal displacements {Ue}. The standard Pump It Up 3.1 Equilibrium Equations David T. Chen O'k first-order approximation to the strain-displacement relationship is, from elasticity theory, {E(x,y,z)}= =-< > < 8v -z 7yz 8w ay 8w 'YzXax +u z Refering back to the linear interpolating functions, the strains can be written, e = a2 Ez a 12 7Ixy = 7yz = a zx= 3 ±a 8 + a11 6 a4 alo Or in matrix form, 0 1 0 0 0 0 0 0 0 0 0 ai a2 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 C a3 0 0 1 0 0 1 0 0 0 0 C a4 0 0 0 0 0 0 0 1 0 0 1 0 0 0 1 0 0 0 0 0 1 {E(x, y,z)} = a 12 And making the substitution for {a} from Equation 3.2, {e (x, y, Pump It Up z)} = [D][A]-1{Ue} = [BII{U'} 3.1 Equilibrium Equations 65 David T. Chen The next step in solving for the tetrahedron's stiffness matrix is relating the internal stresses {o-(x, y, z)} to strains {e(x, y, z)} and to the nodal displacements {U'}. For the special case of a linear, isotropic, elastic material, (3.3) {o-(x, y, z)} = [C]{e(x, y,z)} 1 V V 1 0 0 0 0 0 0 0 0 0 1-2" 2(1-v) 0 0 1-2v 0 V 1 E(1-v) (1+v)(1-2v) 2(1-v) 1-2v 2(1-v) where C is a symmetric matrix E is Young's modulus of elasticity v is Poisson's ratio By replacing the internal stresses {a(x, y, z)} with statically equivalent nodal forces {Fe}, nodal forces can be related to nodal displacements {Ue} to obtain the element stiffness matrix K. This is a well known application of the principle of virtual work. Lets choose an arbitrary set of nodal displacements {uO e ju *e {U**} = {U*e} {U1*e} {U2*e) {U3*e} The total external work represented by this displacement is given by Wext = {Uge}{F } + - -- + {U*e}{F} =e Pump It Up 3.1 Equilibrium Equations David T. Chen If the chosen arbitrary displacements cause a strain {e(x, y, z)*}, the internal work is Wrnt = {E(x, y, z)*}T{O-(X, y, z)} Integrating through the element volume to get the total internal work, WintdV = IV{tE(z, y, 2 )*}To-(, Y, z)}dV From the relationships derived above it is known {Wx, y, z)*} = [B]{U**} {-(x, y, z)} = [C)[B]{Ue} And substituting into the internal work integral WintdV = J{U**e}T [B)T[C] [B]{U}dV Finally, equating the total internal and external work, and dividing through by {U*e}T, {Fe} = [B]T[C][B]dV] {U} = [K]{Ue} Thus, the stiffness matrix for a single tetrahedral element, is the integral [K] = IV[B]T[C][B]dV Where B is the nodal-displacement to internal-strain matrix and C is the strain to stress (constitutive) matrix. If the material comprising the tetrahedron is homogeneous, the matrices under the integral will be constant and so, [K] = (volume of tetrahedron) * [B)T[C][B] Pump It Up 3.1 Equilibrium Equations David T. Chen 3.1.2 67 Mass Matrix M While the derivation for the stiffness matrix is relatively involved, the mass matrix M is often represented by a simple diagonal matrix. Physically this corresponds to the total mass of the element being evenly concentrated at each of the nodes. The approximation inherent in a lumped mass model tends to lessen as more and more elements are used to represent a given physical system. However, because our FEM implementation is geared towards workstation size computers, the tendency will be towards using as few elements as possible. Thus, the consistent mass matrix is used rather than the diagonal lumped mass matrix. The consistent mass matrix is found in a way much like the stiffness matrix. First, note that the internal force per unit volume due to the acceleration of gravity is Fgravity(x, y, z) = p[H]{Ue} where p is the (usually constant) mass density, Ue is the acceleration at each node, and [H]{Ue} is the internal acceleration within the element at point x, y, z. Applying the principle of virtual work as in the derivation of K, the total external work can be written Wext = {U*e}{ F}ravit I And integrating for the total internal work VWindV = J {U*[e}T [H]TP[H]{ e}dV Equating the total internal and external work functions and dividing through by {U*e}T {Fravity} = = Pump It Up [HIp[H]dv {0e} [M]{Ue} 3.1 Equilibrium Equations David T. Chen And so the mass matrix for a single element is the integral [M]= JV p[H]T[H]dV A discussion concerning the damping matrix C will be put off for Section 3.4 covering modal analysis. Isoparametric Interpolation 3.2 3.2.1 Stiffness Matrix In deriving K for the four-node tetrahedron, the element displacements u(x, y, z), v(x y, z), and w(x, y, z) were written as linear functions of x, y, and z with undetermined coefficients {a}. The matrix A was then found from the nodal positions and the matrix H calculated from A 1 to express the state of internal displacement within the tetrahedral element as a function of nodal point displacement. The key to the isoparametric finite element formulation is to establish a direct relationship between the element nodal point displacements and the internal displacements through the use of interpolatingfunctions. Finding K and M for an isoparametric finite element then does not require building the A matrix for a particular set of nodal positions, rather H and B are obtained directly. In general, for an isoparametric element defined by q nodes, the expression for a local point defined by the element is written as in [Bat82], q x(r, s, t) = Z h(r,s, t)xi i=O q y(r, s, t) = [ h;(r, s, t)y; (3.4) i'=0 q z(r, s, t) = Pump It Up Zhi(r,s, t)z, i=o 3.2 Isoparametric Interpolation David T. Chen where hi are the q interpolating functions defined in the natural coordinates r, s and t of the isoparametric element, each of which span -1 to +1. The q nodal positions are given by x;, yi and zi. In matrix notation {X(r, s, t)} = [hi(r, s, t)]{X"} Similarly, the function relating nodal displacements to internal displacement within the element is q u(r, s, t) = Z hi(r, s, t)ui i=0 q v(r, s, t) = Z hi(r,s, t)vi (3.5) i=O q w(r, s, t) = Z hi(r, s, t)wi i=o where the q nodal displacements are given by ui, vi and w;. This is also more easily written in the matrix form, {U(r, s, t)} = [hi(r, s, t)]{Ue} The interpolation functions h; are defined in such a way that the value of hi at r, s and t corresponding to node i is 1 and is 0 at all the other nodes. This property allows the interpolating functions to be determined in a systematic way for any predefined nodal point layout. The specific isoparametric element used in the thesis to model muscle is the twenty-node brick which defines a parabolic interpolation along each of its twelve edges. Refering to Figure 3.2, the twenty nodes are arranged as in Table 3.1. The interpolation functions hi for a brick element with from eight to twenty nodes are given in [Bat82], h Pump It Up = 90 - (g8 + g 1 1 + 916)/2 3.2 Isoparametric Interpolation David T. Chen 70 / Figure 3.2: Twenty-node isoparametric brick, C numbering. adapted from [Bathe] Pump It Up 3.2 Isoparametric Interpolation David T. Chen node rst rat node 0 111 10 0-11 1 2 3 -111 -1-11 1-11 11 12 13 101 01-1 -10-1 4 5 6 7 8 9 11-1 -11-1 -1-1-1 1-1-1 0 1 1 -101 14 15 16 17 18 19 0-1-1 10-1 110 -110 -1-10 1-10 Table 3.1: Local space node coordinates for isoparametric brick hi= gi - (gs + 99 +- 917)/2 + gio + 918)/2 h2 = ha = 93 - (gio+911 h4 = g4 - (912 + g15 + g 16 )/2 h5 = g5 + g13 + g17)/2 h6 = g6 - (914 + gi4 + 919)/2 h7 = h =y g 2 - (9 97 - (912 - (g14 + 9115 +g19)/2 ± g19)/2 for j=8,...,19 where, and # = gi = 0 gi = G(r, ri)G(s, si)G(t, ti) if node i is not included, otherwise r,s,t Pump It Up G(,i ) = }(1 + #i#) G(# #oz) = (1 - #2) for #= for i1 i =0 3.2 Isoparametric Interpolation 72 David T. Chen The twenty interpolation functions were implemented in the C language as formulated above. In addition, C routines were written for the partial derivatives of hi with respect to r, s and t. These derivative functions will be used presently. A source listing for this code is given in Appendix A. An example program using this subroutine library is presented in c20_Natural2Local that does the coordinate transformation of Equation 3.4 to an array of input points given twenty nodal positions {Xe}. typedef float Vector[3]; c20_Natural2Local( node-points, natural, local, num Vector *node-points; /* twenty nodal positions */ /* input natural points */ Vector *natural; /* output local points */ Vector *local; /* number of points */ int num; ) { 10 int i, j; double r, s, t, x, y, z, h, c20_h(; for (i=O; i<num; i++) { r = natural[i][0]; s = natural[i][1]; t = natural[i][2]; X= y = z = 0.; for (j=0; J<20; j++) { h = c20_h( r, s, t, j ); x += h * node-points~j[0]; 20 y += h * node-pointsuj][1]; z += h * nodepointsj][2]; } local[i][0] = x; local[i][1] = y; local[i][2] = z; } Now, to find the stiffness matrix K for a twenty-node isoparametric element, the principle of virtual work is applied as for the four-node tetrahedron [Bat82]. From Section 3.1.1, [K] = [B]T[C][B]dV where B is the matrix that relates nodal displacements to internal strains, that is Pump It Up 3.2 Isoparametric Interpolation David T. Chen au/ax e(Xy, z)} = <= au [B]{Ue} av ay + ax av aw az +ay aw au From the general expression for the displacement interpolating functions given in Equation 3.5, it is easy to see that the matrix form for H is, as a function of r, s and t, ho(r, s, t) 0 0 ... hiw(r, s, t) 0 ho(r, s, t) 0 ... 0 0 ho(r, s, t) ... {U(r, s, t)} = 0 0 0 his(r,s, t) 0 0 0 h 1 (r, s, t) {U'} The functions hi are formulated in terms of the natural coordinates r, s, and t. Hence, the partial derivatives of the interpolation functions in terms of the natural coordinates are straightforward to find. The B matrix, however, relates quantities in terms of the local coordinate system x, y and z. Thus, the 3 x 3 Jacobian matrix that expresses the chain rule is constructed from Equation 3.4, a1 a as a at - ayr azar ax ax Oy az _9 ax at ay as az = [J) - as I a 5r x Dr as at at By[ Ia 5 z) or, in matrix form, - and, for the derivatives with respect to the local coordinate system, {-}= Pump It Up [J-1){-- 3.2 Isoparametric Interpolation David T. Chen 74 In practice, the approach taken to calculate B is to first fill a 3 x 20 matrix with the partials of the interpolating functions ahDr aho as aht [Dr] = at ah, ar ah1 as ah at ahi 9 ar ahi9 --- as aht --- .. at then to multiply by the inverse Jacobian to get the partials with respect to x, y, and z [Dx] = ay ax ahL ay ah, az ahig ..ax ah19 ..ay ah19 ..az = [J'][Dr] and the 6 x 20 B matrix is found, according to the strain-displacement relationship, by filling in from Dx 0 0 0 ah ay 0 0 0 ah1 C-l ay a ax 0 0 ah az )h 0 ah1 ay aDh ax ax [B] = Dz az Now, to obtain the stiffness matrix K requires evaluating the volume integral [K] = IV[B]T[C][B]dxdydz Note that a change of variables in B has been performed from the local coordinate system to the natural coordinate system and so [K] det Jdrdsdt Iv[B]T[C][B] JV where det J is the determinant of the Jacobian matrix. Pump It Up 3.2 Isoparametric Interpolation David T. Chen 75 The last problem to be faced before K can be found for the twenty node isoparametric element is that both the matrix B and det J are complex functions of r, s, t, and so the volume integral can not in general be explicitly calculated. Instead, a numerical Gauss integration is done to find K [Bat82]. Writing the integral as a sum, 3 [K] = [ 3 3 [ F(ri,sj, tk)ai'k i=0 j=O k=0 where F = BTCB det J, and aisJ is a weighting factor that depends on the sample ri, Sj, tk under consideration. This summation process is illustrated in the C routine c20_findK that finds K for a material defined by Young's modulus, Poisson's ratio, and an input set of twenty node points. #include < local/ matrix2.h> typedef float Vector[3]; c20-findK( node-points, youngs-mod, poisson-ratio, K ) Vector *node-points; /* twenty nodal positions */ double youngs-mod, poisson-ratio; /* material properties */ /* output stiffness matrix */ Matrix2-D *K; { int i, j, k; Matrix2-D *B, *C, *mtmp; double r, s, t, detJ; B = m2dcreate(6,60); C = m2d-create(6,6); mtmp = m2dcreate(0,0); m2dseLrc( K, 60 , 60 ); /* C matrix contains material properties */ fe-strain2stress-LinearIsotropicElastic(C, youngs-mod, poisson-ratio ); m2dzero( K ); for (i=0; i<3; i++) { for (j=O; j<3; j++) { for (k=0; k<3; k++) { Gauss-rst( i, j, k, &r, &s, &t ); /* determine sample points */ /* Find B(r,s,t) and det[J(r,s,t)] */ c20-jind-B( node-points, r, s, t, &detJ, B Pump Up Pump It It Up ); 3.2 Isoparametric Interpolation 3.2 Isoparametric Interpolation David T. Chen m2d-transpose( B, Bt ); m2d-multiply( Bt, C, mtmp ); m2dmultiply( mtmp, B, mtmp ); m2d-scale( mtmp, Gauss-weight(i,j,k) * detJ ); m2d-plus( K, mtmp, K ); } } } m2dfree( B ); m2d-free( C ); m2d-free( m2d-tmp ); 40 } The routines to obtain the Gauss sample points and weighting factors are, static double gauss-weights[3] = { .555555555555556, .888888888888889, .555555555555556 }; static double gauss-sample-points[3] = { -. 774596669241483, 0., .774596669241483 }; double Gauss-weight( i, j, k int i, j, k; { return( gauss-weights[i] ) 10 * gauss-weights[j] * gauss-weights[k] ); } Gauss-rst( i, J, k, r, s, t) int i, j, k; double *r, *s, *t; { *r = gauss-sample.points[i]; *s } = gauss-sample-pointsj]; et = gauss-samplepoints[k]; 20 Futhermore, the consistent mass matrix M for the twenty-node element can also be found through Gauss integration 3 3 3 [M] = F(r;, s3 ,itk)oY3 k i=0 J=0 k=0 In this case, F = pHTH and the Gauss sample points and weighting factors are as before. This whole process is explained in much greater detail in Bathe's excellent text [Bat82]. Pump It Up 3.2 Isoparametric Interpolation David T. Chen 3.2.2 Computer Graphics We have seen how the interpolation functions hi for the twenty-node brick element can be used to build the K and M matrices that define the finite element dynamics equilibrium equations. As forces are applied to the finite element model, the nodal points of the isoparametric cube deform dynamically in response. For the purposes of computer graphics, one goal of the thesis was to find a way to use familiar geometric representations, such as polygon and spline based patch descriptions, to define objects but to also have them warp and deform as can the twenty-node brick. This is conceptually very easy to accomplish if the points of a computer graphics object-be they points from a polyhedral or patch representation-are treated as natural coordinates r, s and t that sample an isoparametric space. In this way the twenty-node brick can define a free-form deformation as Sederburg describes for trivariate Bernstein polynomials in [SP861. To describe the effect of a free-form deformation, Sederburg makes the analogy of a parallelepiped of clear, flexible plastic into which is embedded objects that are to be deformed. As the plastic is stretched and twisted, so too are the objects inside. This effect is illustrated in Figures 3.3 and 3.4. Returning to Equation 3.4, the interpolation functions hi can be seen to define a mapping from the natural coordinate system to the local coordinate system where the twenty nodal positions x;, y-, z- are considered control points that determine the particular shape of a deformation. q x(r, s, t) = Z hi(r, s, t)xi i=O q y(r, s, t) = 1 hi(r, s, t)y; i=O q z(r, s, t) = Z hi(r, s, t)zi i=O Pump It Up 3.2 Isoparametric Interpolation David T. Chen Figure 3.3: Undeformed plastic Figure 3.4: Stretched and twisted plastic Pump It Up 3.2 Isoparametric Interpolation David T. Chen 79 So, to dynamically simulate an object, whose geometry is described by point samples connected by polygons or spline patches, as a deformable object that can respond to external forces, three steps must be taken. First, its space is subdivided into some (preferably small) number of adjacent isoparametric finite elements. Then the stiffness and mass matrices are found as has been discussed, and the equilibrium equations solved for a given set of input forces to find the resulting nodal displacements of the isoparametric elements. Finally, using the new nodal positions as control points defining a free-form deformation, the now warped geometric objects embedded in the isoparametric space are rendered to the framebuffer. The underlying assumption made above is that the points of the object to be drawn are in the natural coordinate system r, s, t of the isoparametric element defining the deformation. In general, of course, this is not the case. The nodes of the isoparametric element and the points describing the object geometry are both, in fact, usually defined in the local coordinate system x, y, z. So, given a computer graphics object and a bounding set of isoparametric elements, it must be determined for each point which containing element to use and then a mapping from local to natural coordinates for that element should be performed. That is, the inverse mapping to Equation 3.4 needs to be found for a given set of nodal points and an input point Lo = {xo Yo zo}T. Finding this inverse function is relatively straight forward and comes down to a threedimensional root finding problem which was solved using the Newton-Raphson method as described in [PFTV88]. That is, the problem is to find r, s and t such that [hi(r, s, t)]{Xe} - {Lo} = 0 The key to this is again the Jacobian matrix J that relates partial derivatives of the coordinate transformation function with respect to x, y and z, to the derivatives with respect to r, s and t. The basic procedure is as follows. Given a local space point Lo, and twenty nodal Pump It Up 3.2 Isoparametric Interpolation David T. Chen positions that define an isoparametric space {Xe}, make an initial guess for the natural coordinates of point Lo, call this point N' = {r' s' t'}T. For this first guess, take the natural coordinates of the Euclidean nearest nodal point of the twenty-node brick from Table 3.1. To find out how close this guess is, calculate {#} = {Lo} - [hi(r',s', t')]{X*} Now, construct the Jacobian J(r',s', t'). To find a correction for N', multiply # by the inverse Jacobian to obtain the step to take in the natural coordinate system {6N} = [J)~1{0} and 6N is added to the previous solution vector {New} = {N'} + {6N} The process is then repeated with Nn,, until convergence is obtained. A final check must be made to verify that the r, s and t ultimately found is in the interval [0 - 1]. If not, then the input local point LO is not actually a member of the twenty-node isoparametric finite element defined by {Xe}. This iterative technique for performing the local to natural coordinate mapping is illustrated in the routine c20-Local2Natural that, for a given twenty node element, will do the inverse transformation for an array of input points. The maximum number of trials allowed is 50, but typically the iteration stops after 5 or fewer repetitions. The convergence check is made by summing the absolute values of the elements of # both before and after the multiplication by J and comparing the result against a predefined tolerance. The tolerance used is 10~ which is approximately the machine accuracy of a single precision float. #include <math.h> #include <local/matrix2.h> Pump It Up 3.2 Isoparametric Interpolation David T. Chen typedef float Vector[3]; #define NTRIAL (50) #define TOLF (le-8) #define TOLX (le-8) c20_Local2Natural( node-points, local, natural, num ) Vector *node-points; /* twenty nodal positions Vector *local; /* input local points */ /* output natural points Vector *natural; /* number of points int num; { int i, j, k; Vector N, L, LO; VectorNI *index = vni-create(3); VectorND *beta = vnd-create(3); Matrix2-D *Jac = m2dcreate(3,3); double d, errf, errx; for (i=0; i<num; i++) { LO[0] = local[i][0]; LO[1] = local[i][1]; LO[2] = local[i][2]; ); make_1stLguess-for-natural( node-points, LO, N for (j=0; j<NTRIAL; j++) { c20-Natural2Local(node-points, &N, &L, 1); vnd-set( beta, 0, LO[O] - L[0] ); vnd-set( beta, 1, LO[1] - L[1] ); vnd-set( beta, 2, LO[2] - L[2] ); /* Do coordinate mapping to guess */ /* Calculate beta */ Check for convergence */ for (k=0, errf = 0.; k<3; k++) errf += fabs( vnd-get(beta,k) ); if (errf <= TOLF) break; c20_make-jacobian( node-points, r, s, t, Jac ); /* m2ddecompose( Jac, index, &d m2d-solve( beta, Jac, index, beta for (k=0, errx = 0.; k<3; k++) errx += fabs( vnd-get(beta,k) ); /* Check for convergence again */ N[0] += vnd-get( beta, 0 ); N[1] += vnd-get( beta, 1 ); N[2] += vnd-get( beta, 2 ); /* Update solution */ if = Up mp ItIt Up Pu Pump Solve linear eqns using LU decomp */ ); (errx <= TOLX) break; N[0]; s = N[1]; t = N[2]; 3.2 Isoparametric Interpolation 3.2 Isoparametric Interpolation 30 82 David T. Chen if (!(r > 1. |1 r < -1. 1| 8 > 1Il < - 1. || t > 1. ||t < -1) { natural[i][O] = r; natural[i][1] = s; natural[i][2] = t; m2d-free( Jac ); vnd-free( beta ); vni-free( index ); The first guess is made by finding the node point closest to Lo, as in the following C code static Vector UNITNODES[20] { = {1., 1, 1.} {1., {0., 1., -1 }, {0., {1., 1., 0.}, }; { -1. 1., 1.}, { -1 , 1., - 1.}, {-1., 1., 0.}1, {-1., -1., 1.}1, {-1., -1., - 1.}, {0., -1., 1.}, {0., -1., -1.}, {-1., -1., 0.}, static make-1lstLguess-for-natural( node-points, L, N Vector *node-points; Vector L, N; {1, 0., 1.} {1. 0., - 1.} {1., - 1., 0.} ) { int j, minnode; float cur-min, tmp; float VVdistO; /* find Euclidean distance between two Vectors */ min-node = 0; cur-min = VVdist( L, node-points[0] ); for (j=1; j<20; j++) { if ((tmp = VVdist( L, node-points[j] { cur-min = tmp; min-node = ; )) < cur-min) } N[0] = UNITNODES[min-node][0] ); N[1] = UNITNODES[min-node][1] ); N[2] = UNITNODES[min-node][2] ); This section has introduced the isoparametric finite element formulation and shown how it can be used to construct the dynamic equilibrium equations that are used for the purposes of modeling deformable objects. It has also been demonstrated how the twenty- Pump It Up 3.2 Isoparametric Interpolation 83 David T. Chen node brick element can be used to define a free-form deformation which is used to produce graphical output that visualizes simulation results. For both of these purposes, the interpolating functions hi were used extensively. In the first case to calculate the Jacobian matrix which was used in the Gauss integration of the stiffness matrix K, and in the second to do the coordinate mapping from r, s, t space to x, y, z, as coded in c20_Natural2Local. Because this transformation is used so much, and especially since it is a part of the simulation loop, it is worthwhile to think of a way to speed up the process. The way this was accomplished was to use the symbolic math capability of Mathematica to expand the summation in Equation 3.4 by premultipling the effect of the node points, collecting like terms of the resulting polynomial, and simplifying. For the twentynode brick element this results in a polynomial expression for each of the three primary directions. These polynomial functions are each characterized by twenty coefficients that are in terms of the element nodal positions {Xe}. Using this formulation, it is easy to rewrite the natural to local coordinate mapping routine to be much faster than before. typedef float Vector[3]; c20_Natural2Local-fast( node-points, natural, local, num ) Vector *node-points; /* twenty nodal positions */ /* input natural points */ Vector *natural; /* output local points */ Vector *local; /* number of points */ int num; { 10 int i; double r, s, t, CX[20], CY[20], CZ[20], c20_XO; c20-make-polynomial( node-points, 0, CX ); c20-make-polynomial( node-points, 1, CY ); c20-make-polynomial( node-points, 2, CZ ); for (i=0; i<num; i++) { r = natural[i][0]; s local[i][0] = c20-X( local[i][1] = c20-X( local[i][2] = c20-X( } = natural[i][1]; t CX, r, s, t ); CY, r, s, t ); CZ, r, s, t ); = natural[i][2); 20 } Pump It Up 3.2 Isoparametric Interpolation David T. Chen 84 Where c20_X evaluates a given input polynomial at a particular r, s, t. double c20_X( C, r, s, t ) double * C, r, s, t; d double r2, s2, t2, ans; r2 = r*r; s2 = s*s; t2 = ans= C[O] + C[2] * s * t2 + C[4] * r * t2 * t2 + C[6] + + C[8] C[10] + C[12] + C[14] + C[16] + C[18] * r2 * s * r2 * s * s2 * t t*t; + C[1] + C[3] + C[5] + C[7] * s2 + + + + + * r * s2 + C[19] C[9] * r * s *t Sr s t2 * * r* r2 s* t t * * r2 * s * C[11] 8 ~t C[13] C[15] *r t C[17] * r t Sr * * s2 * t t; return( ans ); The routine to construct the polynomial coefficients, while straightforward is quite long and so is left for Appendix B. Thanks to Steve Pieper for implementing the blending functions in Mathematica and simplifying them. For an interactive graphics application, an objective is to stay rendering bound whenever possible. This means avoiding calculations in the simulation loop that are slower than the time needed to render the final pixels to the display. Comparisons were made using the fast interpolation scheme for objects with different numbers of points both against the straightforward interpolation method and against the rendering time required on an HP graphics workstation using HP's built-in Starbase graphics library in Table 3.2. All times are in seconds. It is easy to see from Table 3.2 that the fast isoparametric interpolation technique developed in this section is over 13 times faster than the standard interpolation method Pump It Up 3.2 Isoparametric Interpolation David T. Chen no. of points 386 1352 8192 rendering time .17 .46 3.5 standard fast interpolation interpolation .56 2.0 12.0 .042 .14 .9 Table 3.2: Run-time in seconds for two isoparametric interpolation implementations and about 3 times faster than the rendering times recorded. Figure 3.5: A bent fork 3.3 Global Matrix Assembling In performing a finite element analysis of a muscle, or any kind of real physical structure, it should always be kept in mind the inherent mechanical idealizations that are being made. Pump It Up 3.3 Global Matrix Assembling David T. Chen Essentially, the displacement based FEM formulation that is used here approximates a given elastic deformable material by discretizing its volume into a collection of elements that can take on certain predefined shapes known as constant strain states. Ideally, a good finite element model will converge to the analytic solution-when one is available-as the number of elements increases. For convergence to this "true" solution to happen, there are two criteria that must be met, that is, the elements must be complete and compatible [Bat82}. Completeness means that the displacement functions of the elements used in the model must be able to represent rigid body motions as well as the constant strain states. It will be seen that these fundamental shapes are determined by the eigenvectors of the stiffness matrix in the next section covering modal methods. Compatibility means that displacement within an element as well as displacement between element boundaries must be continuous. Because the twenty-node brick that is used here describes only the three translational degrees of freedom at each node, compatibility is easily ensured by explicitly joining the nodes of adjacent elements to guarantee that the elements can never separate. This requirement of sharing nodes between individual finite elements naturally leads to the topic of global matrix assembling, which is perhaps most easily explained in terms of a simple example. Given the structure in Figure 3.6 made from two four-node tetrahedron elements, the nodes comprising element one are {0 1 2 3} and those for element two are {O 1 2 4}. The relationship between nodal displacements and nodal forces for the whole assemblage is as before {F} = [K]{U} where K is now the global stiffness matrix that has, in this case, dimension 15 x 15 and the nodal displacements and forces are {U} Pump It Up = Uo U1 U2 U3 U4 3.3 Global Matrix Assembling David T. Chen 87 - Y Figure 3.6: Structure made from two tetrahedron elements {F} = { F0 F1 F2 F3 F4 } With this element and node numbering in place, the local stiffness matrices for each element are first constructed individually. For element one {Fil} = [KIL1]{UL1} and for element two {FL2 } = [KL2]{UL2} These local stiffness matrices are made exactly as described earlier in the chapter and each have dimension 12 x 12 for the four-node tetrahedron element. Care must be taken, however, to keep track of the node numbering for the local K matrices {UL1 Pump It Up u0 U1 U2 U3 3.3 Global Matrix Assembling David T. Chen 88 {UL2 } = UO U1 U2 U4 Now to construct the global stiffness matrix that determines the equilibrium equations for the whole structure, the principle of superposition is applied to the forces acting at each of the nodes. Looking at node 0, it can be seen that there are relevant forces acting from both finite elements, encoded in the top row of each of the local stiffness matrices. Writing the matrix multiplications out, and remembering that each node actually has three degrees of freedom, {Ffl} = {koJ}{Uo} + {ko'}{U 1 } + {ko}{U 2 } + {k {Fo2 } = {koo}{Uo} + {ko}{U 1 } + {kO}{U 2} f}{U3} + {kO}{U 4} The total force acting at node 0 is then the vector sum {Fo} = ({ko} +{koL}) {U0} + ({ko} + {k L}) {U1 } + ({ko} + {ko9}) {U2 } + {k }{U 3 } + {ko}{U 4 } Which defines the first three rows of the global stiffness matrix. The other twelve rows are obtained with an identical procedure by summing the force components acting on the remaining nodes. The global mass matrix needed for dynamics is derived in a wholly analogous fashion by correctly summing the local element mass matrices. 3.4 Modal Analysis 3.4.1 Solving the Equilibrium Equations We have discussed the construction of a set of equilibrium equations that determines the dynamic behavior of a finite element idealization of a given physical structure, by first Pump It Up 3.4 Modal Analysis David T. Chen 89 applying the principle of virtual work to obtain local element matrices and then assembling these into a single set of global matrices that governs the structure as a whole. For the dynamic case, these are written as before Mii + Cit + Ku = R (3.6) Where M, C and K are the mass, damping and stiffness matrices; R is the external load vector; and u, it and ii are the nodal displacement, velocity and acceleration vectors that all have the same rank n. This system can be characterized as a coupled set of second-order differential equations for the displacements u. It is well known that any problem involving ordinary differential equations can always be reduced to an equivalent system of first order differential equations. Equation 3.6 is rewritten, it v(t) = M 1 (R (3.7) - Ku - Cv) (3.8) In this form, the time-varying nodal displacements can be solved by specifying a set of initial conditions and using a suitable numerical integrator such as Runge-Kutta or a predictorcorrector [PFTV88]. The way these equations are typically expressed to a standard differential equation solver is through a user supplied derivs function that calculates dydt at t. derivs( t, y, dydt ) double t; double y[m], dydt[m]; Note that m in this case is two times the number of nodal degrees of freedom, or 2n. The numerical complexity of derivs for this kind of solution is order n 2 for doing the three matrix multiplies necessary to calculate b. Pump It Up 3.4 Modal Analysis 90 David T. Chen The time spent performing a dynamic analysis is typically dominated by the number of calls to derivs. It is possible to take advantage of the block structure of the globally assembled FEM matrices by using a sparse matrix package to speed up the matrix multiplies, but it is possible to do better by first transforming the equilibrium equations into the modal displacement basis. The modal transformation is easy to develop and the discussion here follows [Bat82] and [PW89]. First re-write the nodal displacement vector in the following way (3.9) u(t) = Px(t) where P is a square matrix that represents an as yet undetermined transformation and x is a vector with the same rank as u. The elements of the vector x are called generalized displacements and are analogous to the generalized degrees of freedom that Schr6der writes about in [SZ90]. Substituting this into Equation 3.6 and premultipling by pT yields, M+C +Kx =1 where S= PTMP; 3.4.2 C PTCP; K PTKP; R = PTR The Modal Transformation Now, to obtain the modal transformation, consider the homogeneous equilibrium equations without damping Mii + Ku = 0 (3.10) To solve this equation, assume a solution of the form u = #es"W Pump It Up 3.4 Modal Analysis 91 David T. Chen where 4 is a vector of rank n. This yields upon substitution -w 2 Mo'ei"' + Kej"'t = 0 (3.11) KO = AM4 where A = w Equation 3.11 has the form of a generalized eigenvalue problem. To be able to use the available numerical solvers to find the n eigenvalues A; and eigenvectors 41, this equation needs to be reduced to the standard form K4 = A4. This is done by first finding the Cholesky factorization (matrix square root) of the mass matrix M = SST Substituting for M in Equation 3.11 gives K4= ASST4 and premultipling by S-1 S-1 K4 = AST4 Finally, define the vector $/ = ST$ which yields the standard eigenvalue problem K'4' = A4' (3.12) where K' = S-1KS-T Pump It Up 3.4 Modal Analysis 92 David T. Chen The eigenvalues and eigenvectors of Equation 3.12 can then be determined and found to be # # is = S-I'. Lets write the n eigensolutions in the following matrix form 2 Win where the columns of ( are the eigenvectors and Q2 is a diagonal matrix filled with the #i corresponding eigenvalues Ai = wt?. The eigenvectors obtained in this way have a special property known as M-orthogonality. This means that M = I Where I is the identity matrix. To show this, expand the multiplication for two eigenvectors -, using the expressions for M and #$M# Because the eigenvectors #' # from before = #'TS-1SSTS-IT# span an orthonormal basis, #70#' = 3 6;.3 Where bi is the Kronecker delta which is 1, if i = j, and 0 otherwise. Now write the n solutions to the generalized eigenproblem in Equation 3.11 as K = M4Q 2 Premultipling by bT and using the M-orthogonality of the eigenvectors gives KP Pump It Up = Q2 3.4 Modal Analysis U5 David T. Chen Now it becomes clear that the matrix (b is a good choice for P in Equation 3.9. That is, using u(t) = 4x(t) which relates the mesh nodal point displacements u to generalized displacements x through the eigenvector matrix 4 , the modally transformed equilibrium equations take the form where the eigenvector (3.13) + QIx = qj R S+,pT Ci 4; is called the mode-shape vector for the generalized displacement xi and w, is the corresponding natural frequency of vibration. That is, a single displacement x; effects the shape of the entire mesh through the action of the vector #i at all the node points. These equations totally decouple as long as the modally transformed damping matrix bTC4p is also diagonal. What is often done in practice is to assume Rayleigh damping for a structure, so that C = aM +K where a and # are constants determined either through experiment or to satisfy predefined time decay characteristics. Equation 3.13 can then be written as 3n independent secondorder differential equations Zi + 7i; + WJ X; (3.14) =r; where -;, is the damping factor for mode shape i, which in the Rayleigh case has the form yi=a + o3w 2 So the modal transformation completely diagonalizes the coupled set of differential equations in Equation 3.6. These equations can now actually be solved completely separately from each other, but because of the way forces are calculated it is more convenient to Pump It Up 3.4 Modal Analysis 94 David T. Chen formulate them in a single derivs function. Furthermore, the time complexity for derivs has been reduced from O(n 2 ) to O(n) for finding i from a given set of input forces. Unfortunately, for the kinds of forces we are interested in simulating, the overall complexity will return to O(n 2 ), but more about this in Section 3.4.4. 3.4.3 Computer Graphics As generalized displacements x; are computed, the mesh undergoes changes in shape defined by the eigenvectors #;. These vibration mode shape vectors define the constant strain states for the finite element idealization of a structure to be modeled. That is, any new shape that the structure can assume will be a superposition of some number of the eigenvectors #. Thus, the modal transformation procedure also analyzes a structure by revealing the natural shape changes that it can undergo. For an assemblage of complete elements this will also include the rigid body motion of the structure [Bat82]. For a three-dimensional element, like the twenty-node isoparametric brick that has been discussed, there are six rigid body modes-three translational and three rotational. Since there are 3n = 60 total degrees of freedom for the twenty-node element, the 54 remaining modes each represent a different deformation of some kind. The rigid body modes for a three-dimensional structure are encoded in the first six eigenvectors 0,... , 05 where the corresponding eigenvalues A0,.. ., A5 all have value zero. For the purposes of computer graphics and animation, an additional change of basis is performed for the rigid body modes by replacing these six eigenvectors with the standard translations in the x, y, and z directions and rigid body rotations around the three coordinate axes. This is tantamount to choosing the right control knobs as described in [PW89] so that the dynamic, deformable models can be more easily positioned and controlled. In our case, however, the remaining constant strain modes will be left intact to govern the Pump It Up 3.4 Modal Analysis 95 David T. Chen deformation response due to input forces. More importantly perhaps, by performing this replacement of the first six eigenvectors by simple rigid body translations and rotations, it is straightforward to achieve the effect of a Total Lagrangiananalysis as discussed in [Bat82]. The Total Lagrangian is important when the element bodies undergo large displacements or large rotations, as is typical in computer graphic animations. This is because the global K matrix, as developed above, only properly expresses the nodal relationships in the configuration in which the Gauss integration is performed. Intuitively, we can realize that the Jacobian matrix that relates the natural coordinate system of an isoparametric finite element to the local reference frame, and which plays a primary role in the construction of the stiffness matrix, changes dramatically as the element assemblage undergoes large rotations. For an analysis that takes care of such rotations, the equations of motion are arranged so that external forces always act in the original space of the body, thus obviating the need to recalculate K. By separating the effects of rigid body motion from elastic deformation the required force transformation is simple to compute. This subject will be dealt with in greater detail in Section 3.4.4. Section 3.2.2 discussed how the points of a polygonal or spline based object embedded in the isoparametric space of a finite element mesh can be warped. The modal transformations change this operation little. The only differences are that since generalized displacements are now being solved for, the nodal displacements must be calculated before the rendering step as 3n i=6 Furthermore, the rigid body position and orientation can be simply determined from the first six generalized displacements as a series of standard 4 x 4 affine matrix operations where the three rotations accept angular radians Rz(x 5 ) - Ry(x 4 ) - Rx(x 3 ) - T(xo, x 1 , x 2) Pump It Up = Mrot - Mtrans = Mrigid 3.4 Modal Analysis David T. Chen The first five eigenvector mode shapes #6,... , #10 are illustrated for a single twenty- node brick element and for the Cyberware head model made from three twenty-node bricks in Figure 3.7 and Figure 3.8. Figure 3.7: Mode shapes for twenty-node brick 3.4.4 Deriving Modal Forces To find the forces necessary to drive the modal form of the equilibrium equations, two steps are taken. First the external world space forces, R, acting on the node points of the finite element mesh are found. Then the modal equivalent forces, Rmojal are resolved by performing the transformation discussed above, Rmda = jT R However, because the rigid body translations and rotations are not treated in the Pump It Up 3.4 Modal Analysis 97 David T. Chen Figure 3.8: Mode shapes for Cyberware head matrix i, two further complications are introduced. The world space force R must first be rotated into the original coordinate system (local space) of the dynamic body before the eigenvector multiplication is carried out, and the explicit world space rigid body forces must be computed. The components of the world space force vector R are comprised from a variety of sources-force fields such as gravity, spring/damper systems acting at the mesh node points, constraint goal positions, muscle fiber or tendon forces, and collision/contact forces. The translational part of the rigid body force is found simply by summing the forces acting at the n node points, n Rtrans = Z Ri i=0 Assuming the center of mass of the finite element mesh is at the origin, the rigid body torques can be calculated with an element-wise cross product operation to R and the Pump It Up 3.4 Modal Analysis 98 David T. Chen current world space location of each of the nodal points P, n Pi O Ri Rrot = i=0 To calculate the modal elastic forces that will govern the deformation of the finite element mesh, the elements of R must first be transformed into the body's local space using the inverse of the rotation matrix Mrt defined in Section 3.4.3, Ri,[i] = Ri- M t It is these local space forces that are finally multiplied by the transposed eigenvector matrix to yield the modal equivalent forces, Rmodal = <> R18p Note that because the first six modes have been replaced by explicit rigid body translations and rotations, only elements 6 through n of Rmodal are used. The arrows in Figure 3.9 show the magnitude and direction of world space forces, Ri, acting at the twenty mesh nodal points of a simple cube element. The main force component is from a constraint that drags node 0 of the mesh upwards and to the right to meet the soccer ball (Ro). Forces at the other mesh points are from collisions with the floor and gravity. Note that even though the gravity acceleration is always directed downwards, the force to produce this acceleration points upwards at the corner nodes. This is due to a nonuniform distribution of the cube's mass and is a direct consequence of using the consistent mass matrix discussed in Section 3.1.2. 3.4.5 Mode Truncation The development of the modal transformation, as presented here, was motivated by a desire to speed up calculations within the derivs function called by the differential equation solver Pump It Up 3.4 Modal Analysis David T. Chen 99 Figure 3.9: World space mesh forces for twenty-node brick that is used to integrate the finite element equilibrium equations. The form of Equation 3.8, indicates that solving the standard form of these equations is at least O(3n2 ) for the three matrix multiplies. By determining the answer to the generalized eigenvalue problem and constructing the matrix 4 as a preprocessing step to solving the ODE's, the matrices M, C and K are diagonalized and so it would seem that derivs now has complexity 0(3n). However, because of the way the force vector R is calculated, the solution complexity returns to O(n2 ). That is, finding the modal equivalent force, Rmdaai, to a time-varying external world space forcing function requires the matrix multiply from above, Rmodal = IT Risp Furthermore, to enforce the kinds of constraints desirable for computer animation, the current world space mesh nodal point locations must be updated within derivs as well. Pump It Up 3.4 Modal Analysis 100 David T. Chen One such constraint would be the attachment of a mesh point to a world space location, as in Figure 3.9. The mesh displacements, u(t), are then calculated within derivs from the generalized displacements, x(t), u(t) = Ix(t) At first glance then, it may appear that the modal transformation has done little except change the complexity of derivs from 0(3n 2 ) to 0(2n 2 ). In practice, however, there can be considerable savings with this method. In [Bat82], Bathe states that frequently a good approximate solution to the actual response of a real physical system can be gotten by considering only a small fraction of the total number of decoupled equations. That is, by considering only equations i = 1,...,p of Equation 3.14 where p << n, a good approximation to the physical response of a system can still often be obtained. By truncating the decoupled set of equations to include only the first p modes yields three advantages. First, only the first p eigenvalues and eigenvectors need to be found. Second, the two matrix multiplies with D that are now calculated by derivs can instead be written as the sparser summations, P u(t) = (ixi(t) i=6 Most importantly in terms of computational efficiency, however, mode truncation can lead to many, many fewer calls to the derivs function by the differential equation solver. The eigenvalues Ai = w? found from the stiffness matrix K determine the frequency of vibration for the associated mode shape vector 41. Depending on the frequency content of the input forcing function, different combinations of modes will be excited. A standard ODE solver with adaptive stepsize control will automatically subdivide its interval to capture the highest frequency changes. Thus, by bandlimiting the impulse response of the system through mode truncation, fewer calls to derivs will result. Pump It Up 3.4 Modal Analysis 101 David T. Chen The tradeoff inherent in mode truncation is computational speed versus the accuracy of the final solution. One way to estimate the effect of mode truncation on the quality of a simulation is to consider that for modes larger than p, the effective force will be zero, so that the mode shapes 4; for i > p will not have any effect. From the previous section, it was seen that for our modal formulation, the input vector R contributes to both rigid body and deformation force quantities, R Rtrans Rrot Risp Rm i = CDRisp So the effect of truncating modes will not produce any error in the important rigid body response of a system, but could lead to underestimating the maximum deflections generated. Futhermore, because modes are deleted, the result is always to remove force from the system. Hence the solution found in this way will be an upper bound to the solution expected by making p = n. From [Bat82], it is known that the number of modes to be used to model a system depends on the characteristics of the structure itself and the spatial distribution and frequency content of the loading. Bathe gives the example of earthquake loading where in some cases only the ten lowest modes need to be analyzed, although the order of the modeled system n may be larger than 1000. On the other hand, for high frequency blast loading, p may need to be as large as 2n/3. For the frog gastrocnemius discussed in Section 6.1, the mode shape vector corresponding to the simple longitudinal extension and shortening expected upon isotonic muscle activation was found, and p set to be 2-3 times this value. For the example of Section 6.1, 014 corresponds to this mode and p is set to 40. The forces developed upon contraction have a relatively smooth characteristic as seen in the plots of Section 2.2.3. Bathe has developed an error measure for mode truncation that uses UP, the displace- Pump It Up 3.4 Modal Analysis 102 David T. Chen ment response predicted by mode superposition when only p modes are included, | R(t) - [MUP(t) + KUP(t)] || R(t) || Unfortunately, this is difficult to compute given the details of the modal analysis programs developed here. First, EP(t) does not include the effects of damping. Damping is a part of our analysis, but not through the explicit construction of a global damping matrix C. Second, the forces corresponding to rigid body motion would have to be summed in some way with the MUP(t) terms in order to take care of all inertia components. Futhermore, though EP(t) measures how well the nodal point loads are balanced by inertia and elastic forces, it is still not entirely clear where the line should be drawn to be able to say that EP(t) should be below some prescribed value. Hence, the approach taken is to provide a simple interactive method, based on the techniques of Section 5.5, to allow the user to set p for a given simulation. Relevant engineering quantities, such as the natural frequency for a mode, the resonant frequency, and mean decay lifetime are also presented so that the user can make an informed decision for p based on what is known about the loading conditions to be used. A dialog box that provides this functionality is shown in Figure 3.10. Pump It Up 3.4 Modal Analysis David T. Chen 103 iX 202.7 DtE Dr S24,32 4.4 Natural Frequencs 1.402 Resenet Frequencyj 0.06222 Neal Ilecay LiVstine Figure 3.10: Modal popup menu Pump It Up 3.4 Modal Analysis David T. Chen 104 Chapter 4 Musculoskeletal Structure The idea of capturing the complete internal anatomy of frog and human legs through MRI or other digitizing processes was discussed in Section 2.3. The important information to be preserved was the relative in vivo geometry of distinct muscle masses and bone. To dynamically simulate a whole musculoskeletal structure, however, is certainly not a simple task. Many problems are introduced by considering the whole system. Besides the highly non-linear internal muscle forces discussed in Section 2.2.3, new forces must be calculated for the fascia attachments modeling contact between bone, muscles and skin. A simulated skeleton can be driven by muscle forces calculated at the tendon attachment points. Higherlevel coordination and reflexes can be modeled through a computational central nervous system. Though much of the implementation of these problems will be left as "future work", this chapter will try to point out some useful representations and present a framework around which the musculoskeletal structure can be captured by extending the techniques heretofore developed. Pump It Up Musculoskeletal Structure 105 David T. Chen 4.1 Skeleton Kinematics 4.1.1 Denavit and Hartenberg Joints Using the formalism developed by mechanical engineers and robotics researchers, jointed figures generally are considered to be networks of linked manipulators. The legs and arms of a human skeleton, for instance, can be described as manipulators attached to a common fixed reference frame centered on the body. The hands and feet in this case play the role of end effectors. A very common coordinate frame representation in use is that of Denavit and Hartenberg [Pau8l]. The DH notation represents each of serially linked joints with four real numbers that specify a new position and orientation relative to the previous coordinate frame. Paul establishes the relationship between joints n - 1 and n with the following series of rotations and translations, 1. rotate about zn_ 1 , an angle, O, 2. translate along z,_1, a distance d 3. translate along rotated X-1 = Xz a length an 4. rotate about Xn, the twist angle an The DH representation explicitly defines joints that are either revolute or prismatic. To model a spherical joint, a system of three coincident revolute joints, oriented so that any two of the defined axes of rotation are not parallel, is used. The treatment here, as the emphasis is on approximating human anatomical systems, will deal almost exclusively with revolute joints. The movement of genuine biological joints, of course, is much more complicated and is defined by the contact of shapen articular cartilage bone ends held together Pump It Up 4.1 Skeleton Kinematics 106 David T. Chen 106 David T. Chen Joint n+1 Joint n (4n Joint n-1 X- On-I Link n Link n+1 Link n-1 Link n-2 Figure 4.1: Denavit and Hartenberg link parameters [Pau8i] by ligaments [Kel7l]. A single DH quadruple is used to represent each degree of freedom of the manipulator. A simple lever arm can be described with one DH quadruple, while a spherical joint requires three. The human upper arm can be idealized as a kinematic system composed of five links and eleven degrees of freedom, and so requires eleven DH quadruples to represent the joint coordinate frames. These eleven degrees of freedom correspond to three DOFs each at the clavicle, scapula and humerous and one DOF at both the ulna and radius. A further complication is admitted because it is not always possible to rotate the subsequent (n + 1) coordinate frame to line up as desired since the twist angle a produces a rotation only around x,. Thus, it is sometimes necessary to introduce "dummy" joints that do not move, but only serve to modify the coordinate frame orientation. The DenavitHartenberg parameters used for the left arm model are presented in Table 4.1. The dummy Pump It Up 4.1 Skeleton Kinematics 107 107 David T. Chen David T. Chen joints are indicated in the frozen column. joint [name 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 clavicle scapula humerous ulna radius wrist I da a frozen 0 0 0 90 100090 00 5.30 60 0 0 90 1000090 0 0 2.30 00 0-90 800090 500090 900100 10000 90 -90 0 0 90 90 0 8.6 90 0 0 0 90 0 0 6.6 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 0 Table 4.1: DH parameters for human left arm While these kind of joint systems do not inherently contain any muscle or dynamics information, they are particularly convenient vehicles on which to perform kinematic simulations. Methods that have been proposed to perform locomotive control of such articulated systems include the use of finite state machines arranged in a hierarchal control structure by Zeltzer, Jacobian control and dynamic simulation. Zeltzer in his PhD thesis [Zel84] talks about the task of controlling a multilink biological motor system as a degrees of freedom problem. That is, there are many more degrees of freedom that need to be specified than can be comfortably conceptualized. His solution is to use a form of functional abstractionby introducing "local motor programs" (LMP's) that directly control specific classes of motions for a particular set of joints. These LMP's, can be viewed physiologically as low-level "reflex processes" which are regulated by higher-level Pump It Up 4.1 Skeleton Kinematics 108 David T. Chen controllers, or skills. At the highest level is a task manager, that takes goal descriptions from the user-"Go to the door and open it", and decomposes them into lists of component skills. In addition to the work of Zeltzer, this kind of system has been implemented in [Str9l] and [Joh9l]. 4.1.2 Inverse Kinematics One way of implementing LMP's is with inverse kinematics, a well-known technique developed by robotics researchers that solves the degrees of freedom problem for a manipulator arm by requiring only the specification of the end effector's position and orientation. The essential component of this method is the Jacobian matrix, which directly relates the end effector linear and angular velocities - to rotary dtdt joint velocities !. thesis, Ribble In hissteiRbl [Rib82] uses inverse kinematics to control a walking human skeleton, and specifies hardware to perform the needed computations quickly. The shape of the Jacobian is n by m where n is the number of known end effector velocities and m is the number of free joints in a single manipulator. The number of knowns is usually six, if both end effector linear and angular velocities are specified, or three if only linear velocities are available. As was seen before, a typical manipulator has between four and twenty degrees of freedom. So, Jacobian Control of a robot arm implies finding rotary joint velocities from goal end effector velocities, that is, inverting the Jacobian to find L from L. But, as the Jacobian is not generally a square matrix, the Moore-Penrose pseudoinverse of the Jacobian matrix is typically used. The pseudoinverse leads to the minimum norm solution for a particular under or over-constrained linear system. To model an entire skeleton, a separate Jacobian is needed for each end effector that will be independently motile. Thus, specifying skeleton motion becomes a problem of correctly solving for the paths that each of the hands Pump It Up 4.1 Skeleton Kinematics 109 David T. Chen and feet will follow. Because the system of equations defined in this way is in most cases underconstrained, a further degree of control over the motion can be obtained by specifying a secondary goal vector that controls the relative values of the final velocities computed for each DH joint. For example, Figure 4.2 shows the skeleton arm swinging from back to front. The motion was defined by using the soccer balls as beginning and ending constraint points for the fingertip end effector. Figure 4.2: Inverse kinematically controlled skeleton motion Finally, dynamic simulations of articulated bodies have been done in the computer graphics community by Armstrong and Green [AG85], Wilhelms [Wil87], Bruderlin [BC89] and McKenna [McK90]. Forward dynamics can be done if the limb inertias can be calculated and relevant external forces are known. Featherstone [Fea87] writes the equations of motion Pump It Up 4.1 Skeleton Kinematics David T. Chen 110 for an articulated robot as, Q = I(q)j + C(4, q, x) where Q is the vector of torques acting at the joints, q, 4, and 4 are the joint variables and derivatives for the robot and C is a vector of forces not dependent on the robot's acceleration, including gravity and other externally applied forces. In general, dynamic simulations produce more realistic, but harder to control motions than purely kinematic simulations. 4.2 Muscle Coordination Dynamic biomechanic models of musculoskeletal structures have been made in [AD85], [Hat76], [McM84]. With these models, the modus is usually to study individual limbs such as the leg, rather than examining the body in toto. One important topic of such research is to examine how muscles can be controlled to produce specific motions. For example, Audu [AD85] discusses a simple lower limb linkage with one degree of freedom at the hip and another at the knee. He compares the effect of different lumped muscle models, most variations of Hill's, that control the leg in performing a minimum time kick, illustrated in Figure 4.3. The minimum time kicking problem was posed in [Hat76]. The leg initially hangs free and is then kicked forward as quickly as possible to a predetermined position. At the end, both 01 and 02 are specified and the knee velocity 62 is zero. The solution to this problem lays out control histories for the five muscle actuators so that the kicking time is at a minimum and the final joint angles are met within some tolerance. The strategy that Audu outlines is based on techniques from optimal control theory for finding the best way to activate the muscles. Another approach to producing coordinated muscle group action has been suggested Pump It Up 4.2 Muscle Coordination David T. Chen 111 4 2 5 61 Figure 4.3: Lower limb model for minmum time kicking problem. The angle 01 defines the hip. The single DOF 02 is at the knee. Lines 1 through 5 define muscle groups acting on the limb. [AD85] by Wood [WMJ89] [Woo76]. His method seems more easily modularized and extensible to modeling an entire 3D musculoskeletal system than that from Audu, and so is presented here. Wood develops anatomy matrices for musculature that relate muscle forces to torques about specific joints. This can be written for the Am(jk)= ((Xk j-th joint and k-th muscle as, - Z 3 ) 0 Lk) - U3 where from Figure 4.4 it can be seen that Am(jk) is the (time-dependent) scalar lever arm which converts muscle force Fm(k) into a scalar torque Mm(j) about joint (Uj, Zj). The line-of-action for the muscle force Fm(k) is defined by the unit vector Lk, and the point of attachment is Xk. If there are several muscle forces acting about joint moment for musculature Mm(j) about j then the total net is given by the summation over k, Mm(j) = Am(jk)Fm(k) Pump It Up j, (4.1) 4.2 Muscle Coordination David T. Chen 112 Figure 4.4: Muscle acting about the revolute joint defined by unit vector U3 passing through point Zj. [Woo76] This relationship can be extended to handle the effects of gravitational and ligament forces in an analogous fashion by constructing additional matrices. Wood, in his research of prosthetic control, estimated muscle forces from EMG signals collected by electrodes connected to the skin. A linear recruitment relationship, as well as a Hill-type muscle model were used to find these forces. These are then transformed into joint torques by the anatomy matrix, and the torque value used to control the joint actuators of an artificial limb. By inverting the matrix in Equation 4.1, values for muscle force Fm(k) can be found simply from known joint torques. Thus the anatomy matrix can also be used as part of a muscle control mechanism in which a higher-level planning system first estimates the joint moments needed to produce a desired movement. Because the number of joints is typically much less than the number of muscles, Am(jk) is underconstrained, and so the same pseudoinverse techniques that are described by Ribble to perform skeleton control Pump It Up 4.2 Muscle Coordination David T. Chen 113 can then be used to find the vector of muscle forces necessary to produce the specified action. Patriarco [PMSM81] has discussed some of the physiological issues behind different optimization functions (secondary goals) for the determination of muscle forces in this way. 4.3 Attachments, Collisions and Constraints Besides skeleton representation and muscle coordination, a realistic 3D musculoskeletal model must have a mechanism for enforcing contacts between colliding muscle masses and between muscle and bone through fascia attachments. To meet the goals of computer animation, easy-to-create sequences of complex deformable objects are possible only if techniques for automatically simulating the effects of real physical objects are provided. In Chapter 3, the finite element method was developed so that it could be used to make computer animations of a multitude of visco-elastic models. Here the discussion concerns calculation of the nodal point force vector R(t) so that attachments, collisions and contacts can be realistically simulated. Platt [PB88], [Pla89] describes many different methods that can be used to constrain the solution of systems of differential equations by calculating constraint forces. One such technique, appropriate for deformable models, is reaction constraints (RC's). Reaction constraints are applied to single mass points of a discretized body. RC's work by first calculating the net force active at a point due to physics or other kinds of constraints, call this Fin. The RC then projects out the component of Fin in the direction of the constraint, yielding Funconstrained. Next, Fconstrained in the direction of the constraint is calculated to yield a critically damped motion that satisfies the constraint. The resultant force to be applied to the point, Fo 0 t is simply the sum Funconstrained + Fconstrained. The concept is illustrated for a single mass point in Figure 4.5. Pump It Up 4.3 Attachments, Collisions and Constraints David T. Chen 114 Fnonnal FiC Funconstrained Ftangent Fconstrained F constraint manifold Figure 4.5: The constraint goal is to place the mass point on the line. Fin pushes the point up and right. The component Fnor,nal is undesirable, Fangent is acceptable. The force Fconstrained is created by the constraint and sums with Funconstrained to produce Foot. adapted from [Pla89] There are two advantages to this technique. First, it is simple to implement. To attach a node of the finite element mesh to a point in space, Fconstrained is found simply as a spring force. Second, unlike a spring, the desired constraint can be met exactly without using a high stiffness value. The reaction constraints executed in the thesis can attach a nodal point to a world space location, and model collisions of the finite element mesh against algebraic surfaces or against arbitrary polyhedral objects. This is done within the derivs function by updating the mesh displacements for the current time and measuring how far the constraint is from being satisfied. The nodal force vector R(t) is then calculated to move the mesh points closer to the constraint manifold as discussed above. The collision analysis software developed for the thesis is a modified version of the algorithm presented in [MW88]. Because a vector normal to the constraint surface is required to generate forces in the proper direction, collisions are always calculated using the mesh edges. An edge-polygon intersection routine from a raytracer is used to determine the polygons that define the collision. The force Fconstrained is in the direction of the intersected polygon and is scaled by the depth of penetration. Example animations using these Pump It Up 4.3 Attachments, Collisions and Constraints David T. Chen 115 115 David T. Chen constraints are presented in Section 6.2. Pump It Up 4.3 Attachments, Collisions and Constraints David T. Chen 116 116 David T. Chen Chapter 5 Implementation 5.1 The 3d Animation/Dynamic Simulation System One goal of the thesis work is to make a "testbed" system to help script procedures for computer animation, develop algorithms that control dynamic simulation, and that will help us build interactive applications. The software for the resulting program, 3d, is being developed on an HP TurboSRX graphics workstation running UNIXTM. The approach is to make a simplified version of an interactive command interpreter like BASIC or LISP, that has many special purpose rendering, dynamics, numerical math, and user-interface functions all integrated at a relatively "high-level". The entire 3d program has a binary image size of only 2.6M which includes the RenderMatic software A-buffer renderer. However, it is the workstation's ability to draw pictures quickly with its special purpose hardware that is the key to the approach taken here in designing the system. The hope is that 3d will allow simple design of new animations, improved dynamics algorithms and rapid interface prototyping. The work in this area is inspired by bolio [ZPS89] [Pie9O] and corpus [McK90], two other command interpreter programs written for the HP workstation here in Pump It Up Implementation David T. Chen 117 the Computer Graphics and Animation Group. The 3d program is based on the Tcl embedable, application-independent, "tool command language" from U.C. Berkeley [Ous9O]. Tcl is distributed as a C library package and is designed to be used in many different programs. Included with the library is a parser for a simple but fully programmable command language as well as a small collection of built-in functions that support general-purpose language features such as variables, lists, expressions, conditionals, looping and procedure definition. An instance of an application program based on Tcl, such as 3d, extends the basic set of Tcl commands with any number of application-specific commands. The Tcl library also provides a set of utilities that simplify defining these application-specific commands. The application-specific code for 3d has been developed on top of the RenderMatic C library of graphics and rendering software. The command interpreter has over 700 built-in and application-specific functions. There are primitives for rendering and graphics, math, matrix and vector operations, general data structure manipulation, Denavitt and Hartenburg joint description, finite element dynamics and X/Motif interface building. The intent of combining this functionality into a single program is to allow easy prototyping of different graphics-based interactive applications. There is a two-tiered approach to developing software using 3d. First, because Tcl allows procedure definition, it is easy to make collections of useful subroutines in the interpreted language that can control object, light and camera motion. One of the main benefits of creating an interpreted layer of language is that development of animation scripts can be very rapid. Second, pieces of code that must run rapidly or interactively can be written in C and then easily imported as new application-specific functions for the command interpreter. It is important to note that these functions can usually be prototyped first as Tcl procedures (tclprocs) before implementation in C. In this way a "top down" pro- Pump It Up 5.1 The 3d Animation/Dynamic Simulation System David T. Chen 118 Figure 5.1: The 3d Animation/Simulation System gramming style is encouraged. The rest of this chapter will briefly describe the syntax of the Tcl language, the data structures that are used in 3d, and quickly go over some of the application-specific commands that are available. Lastly, we will describe a simple interactive application defined using the system. 5.1.1 Tcl Language Syntax This section is largely from [Ous9O] and is included so that later examples will make more sense to those unfamiliar with Tcl programming. The Tcl syntax is similar to that of the UNIX shell. A command is simply one or more fields separated by blanks. The first field is the name of the command, which can be either a built-in or application-specific command, or a tciproc constructed from a sequence of other commands. Subsequent fields are passed to the command as arguments. A newline (\n) separates commands as do semi-colons (;). Every Tcl command returns a string result upon evaluation or the empty string if no return Pump It Up 5.1 The 3d Animation/Dynamic Simulation System David T. Chen 119 is appropriate. Additional constructs give Tcl a LISP-like feel. Comments are delineated by a pound sign (#). The backslash character (\) denotes line continuation, or escapes special characters for insertion as arguments. Curly braces ({}) can be used to group complex list arguments. For example, the command set a {leo cga {sprockets cheeba} hoot} has two arguments, "a", and "leo cga {sprockets cheeba} hoot". This command sets the variable a to the string defined by the second argument. Square brackets ([1) are used to invoke command substitution. Everything inside of square brackets is treated as a command and evaluated recursively by the interpreter. The result of the command is then substituted as the argument in place of the original square bracketed string. For example mult [plus 1 2] 2 returns 6 because the command "plus 1 2" returns 3. Finally, the dollar sign ($) is used for variable substitution. If the dollar appears in an argument string, the subsequent characters are treated as a variable name, and the contents of that variable are then substituted as the argument, in the place of the dollar sign and variable name. For example set a [plus 1 2] mult $a 2 returns 6 as in the previous example because the variable a has the value 3. Pump It Up 5.1 The 3d Animation/Dynamic Simulation System David T. Chen 5.1.2 120 3d Data Types There are eight primary types built into 3d. These types are polyhedral objects (obj s) used primarily as rendering geometries, texture-maps (maps) that can be applied to obj s, Denavitt and Hartenberg joint chains (dhc), two-dimensional matrices (m2d), one-dimensional vectors of double precision numbers (vnd), vectors of integers (vni), dynamic objects (dynobjs), and strings (str). Many of the application-specific 3d commands operate directly on these types. For each of these primitive data types, there is a constructor command that creates the C data structures that are needed and a special searchlist file (sif ile) that is flagged to indicate its type. The sif ile name can be used later to refer back to the newly created structures. To illustrate, the constructor command to instance a polyhedral object is -- io file.name o instance object where "file-name" is the name of an OSU file, and "o" is the name of the obj sif ile to create in 3d. When this is invoked at the 3d prompt 3d> io /u/dead/data/cutcube cc cc an obj named cc is created from the OSU file "/u/dead/data/cutcube". To examine the names of available sif iles, the listing command is can be used 3d> is - object cc The intent was to make the sif ile commands look as much like the UNIX filesystem calls as possible. Directory trees can be made using the mkdir command. The animation state can be stored in a hierarchally organized way. Arbitrary combinations of the 3d types Pump It Up 5.1 The 3d Animation/Dynamic Simulation System David T. Chen 121 can be created and stored for easy access in directories. This is the way 3d implements data structures made from one or more of the primary types. The dynamic object, dynobj, is created as a directory and makes extensive use of this idea as will be seen. 5.2 Graphics and Rendering The rendering and graphics application-specific 3d commands are written using the Ren- derMatic C library, written by myself, Brian Croll and Alex Seiden. Using RenderMatic, it is very easy to setup a scene and control the objects, view, lights and rendering style. For example, to make a "cutcube" object spin, the C program is #include <local/3d.h> main() { int i; OBJECT *obj; obj = InstanceObject("/u/dead/data/cutcube"); View(-7., 20., -10., 0.); 10 for (i=0; i<30; i++) { obj-rotate(obj, 'z', 5.); RenderMaticO; } To do the same thing using 3d is even simplier because the commands can be typed directly into the interpreter with no need for ancillary compilation and linking phases. io /u/dead/data/cutcube cc view -7 20 -10 0 for {set i 0} {$i<30} {set i [plus $i 1]} { ro z 5 cc render } Pump It Up 5.2 Graphics and Rendering 122 David T. Chen 5.2.1 Objects Polyhedral objects are instanced from OSU files by the io command as seen above. An obj is made that other commands can easily access to change the color, shading, position, shape, and other graphical attributes of the underlying polyhedral object. Some of these commands follow io file-name o instance object to x y z obj ro axis a obj so x y z 01 reo 01 ... co Er g b] o shadowo [01l] o shade [d s e a] o translate object rotate object scale object reorigin object color object turn shadows [onloff] for object object shading parameters facet object smooth object object wsp-centroid dump point/polygons of object local object matrix phong shading gouraud shading harden object with local matrix object vertex facet 01 ... smooth 01 ... centroid obj dumpo [file] o matrix [ml ... m16] o phong 01 ... ... gouraud ol harden ol ... pt i Ex y zI o 5.2.2 Camera The virtual camera used in RenderMatic and 3d is that described by Alvy Ray Smith in [Smi84]. The world space coordinates are right-handed with x to the right, y into the screen and z up. Direct control is given to allow manipulation of the viewpoint, view-normal and view-up vectors. Convenience commands are provided to set these view vectors, the field of view, and the view window shear. Because, there is always a single active view, no constructor command is required to implement the synthetic camera. A partial listing of the view commands follows Pump It It Up Up 5.2 Graphics and Rendering 5.2 Graphics and Rendering 123 123 David T. Chen David T. Chen view d a p r fullview x y z a p r lookat EoIx y z] roll vheading vp Ex y zI vn Ex y z] vu [x y z] vdepth [near far] fov [val] vdist [dist] vwin [cu cv su sz] vpersp [01] vsave vrestore 5.2.3 -- set view with ''dist azimuth pitch roll'' vp = (x y z), vn = f(azimuth, pitch, roll) -- look at point or object -- -- current azimuth, pitch and roll --- view point view normal -- view up -- view depth -- field of view --- view distance view window -- perspective or orthographic view -- save current view -- restore to current view Lights Arbitrary numbers of point or spot lights can be created to illuminate a scene. Control is available to set lighting parameters such as light position and light color. For spot lights, the shade angle can be set, and the light made to cast a shadow in the software renderer. Like the view, lights are considered a global scene property and so no slf ile is made when new lights are created. Multiple lights are differentiated by their names. lcreate 1 lclose 1 llights lon 1 -- create global light -- delete light --- list all lights turn light on loff 1 lcolor Er g b] 1 -- turn light off -- light color lpos [x y zI 1 -- ldir Ex y z] 1 -- lpointat Eolxyzl 1 -- 1spot 1 lpoint 1 -- light position light direction point light at xyz or object make light a spotlight lshadeangle [a] 1 1shadow [name] 1 -- lshadowdim Ew hI 1 -- Up It Up Pump It Pump -- -- make light a pointlight light shade angle light shadow file name light shadow file dimensions 5.2 Graphics and Rendering 5.2 Graphics and Rendering David T. Chen 124 124 David T. Chen 1shadowden [d] 1 5.2.4 -- light shadow density Rendering There are two different rendering modes built into 3d. The hardware renderer is written on top of the HP Starbase Graphics Library, and is used for quick visualization and interactive scene design. The software renderer is the A-buffer scan converter in RenderMatic and is used to draw final versions of scenes to videotape. The render command invokes one or the other of these options depending on the state set by the hardware command. The extra features of the software renderer include phong shading, anti-aliasing, transparency, haze, shadows, and texture and reflection mapping. render hardware [110] doublebuffer [110] antialias [110] nopasses [num] quick [val] dither [amplitude] screensize [x y x1 yl] render2file [im al z] bg [r g b] hazelevel [hl] hazedist [hd] 5.3 render scene hardware render render doublebuffered antialiased render number of passes to render scene render with obj bboxes if nopolys > val anti-contouring dither amplitude screen min and max files to create for software render background rgb haze level [0-1] haze distance [near-far] Numerical Math Much of the power of 3d comes from the numerical math capability that it has. There are simple commands that operate on lists of numbers, like 3d> sqrt [plus [mult 3 31 [mult 4 4]] 5 Pump It Up 5.3 Numerical Math 125 David T. Chen Or, to make sure the cutcube object cc is centered at the world space origin, to [mult -1 [centroid cc]] cc Additionally, there is a 4x4 matrix stack (ctm) that can be used to define affine transformations for obj s and three slf ile types that implement a matrix math package. 5.3.1 Matrix Functions Because most of the finite element equations developed in Chapter 3 are expressed as matrix relationships, it is important that 3d include some method for handling two-dimensional arrays. To accomplish this, three new types are introduced. The m2d is a 2D array of double precision numbers, a vnd is a one-dimensional vector of double precision numbers, and a vni is a vector of integers. Most of the commands that follow can accept various combinations of these three types as input. The exact operation performed will depend on the organization of the input string. For example, m2copy can accept either two m2ds, two vnds, or two vnis as input. Other combinations will generate a syntax error. m2create [r c] m vncreate [n] v vnicreate [n] vi -- m2dim Er cn] my -- create m[r][c] of doubles create v[n] of doubles create v[n] of ints matrix/vec dimensions m2dump mv -- print all elements of matrix/vec } my m2write file my m2read file my -- load all elements of matrix/vec write binary image of my to file read binary image of my from file m2load {e1... --- --- m2ele {{r1 r2 rs} {cl c2 cs}} Ex] my -- elements of matrix/vec m2copy mvl mv2 m2equal mvl mv2 m2scale [mv] sca mvr m2mult mvl [mv] mvr Up It Up P ump It Pump -- copy mvl to mv2 -- mvl == mv2 -- mv[r] * sca = mvr mv1 * mv[r] = mvr -- 5.3 Numerical Math 5.3 Numerical Math 126 126 David T. Chen David T. Chen mvi + mv[r] = mvr m2plus mv1 [mv] mvr m2minus mv1 [mv] mvr m2transpose [m] mr vnlength v vnsum v vnnorm [v] vr vndot vi v2 vncross vi v2 v3 m2invert Em] m2 m2lud b A x m2pinsg b A x m2pisg b A z x m2decompose m vi m2solve b LU vi x m2improv b A LU vi no 5.3.2 mvi - mv[r] = mvr transpose( m[r] ) = mr return length of v return sum of elements of v vr = |v[r] | vi dot v2 vi cross v2 = v3 m2 = inv( m[21 ) find vector x such that b = Ax find vector x such that Ax - b is minimized find vector x such that, (b-Az) = A(x-z) LU form of m, vi is new row order find x given b using LU form of A, ie. b=Ax iteratively improve x from solve no times Netlib Functions Because C does not have any explicit facility for defining two-dimensional arrays, the twodimensional matrix functions were implemented as a subroutine library called libm2.a. For the harder numerical problems, it is advantageous to turn to the more established FORTRAN programs available through netlib. Code from eispack is used to find the real and imaginary eigenvalues and eigenvectors of general matrices, or the real eigenvalues and eigenvectors of symmetric matrices. Code for choelsky factorization is taken from linpack to solve the generalized eigenvalue problem as discussed in Section 3.4.2. m2eig-rg m vr vi mr m2eig.rs m vr mr m2chdc Em] mr Pump It Up ---- eigenvals of m in vr/i, eigenvecs in mr eigenvals/eigenvecs of symmetric matrix m cholesky-decomposition( mEr ) = mr 5.3 Numerical Math 127 David T. Chen 5.4 Dynamic Objects The system of ordinary differential equations that results from a finite element analysis can be effectively solved using a numerical integrator as discussed in Section 3.4.1. Rather than writing a custom ODE solver, the LSODE code available through netlib is employed for this purpose. LSODE solves the initial value problem for stiff or nonstiff systems of first-order ODE's, of size neq, of the form dy = f;= f(i, t, y1, - -,yneq) The function f is the user-defined derivs function that characterizes the exact nature of the ODE system. The FORTRAN interface to this call is subroutine f (neq, t, y, ydot) dimension y(neq), ydot(neq) in which the vector function f loads ydot(i) with f(i). LSODE, written by Alan Hindmarsh, contains an implementation of the AdamsBashforth predictor-corrector, which is the LSODE method that is primarily used here. The mechanism that 3d uses to access the numerical integrator is the dynamic object dynobj. A dynobj is created by the constructor command dyncreate noeqns d -- make a dynamic object where in this case, noeqns is the number of second-order differential equations to be solved. One point worth noting is that the predictor-corrector, while relatively fast, does not handle discontinuous input forces very well. In practice, the integrator must be reinitialized before such forces can be applied [Lot84]. The command dyncreate makes a directory named d and fills it with m2ds, vnds, and strs that define the dynamic state. For example, a rigid body can be described as a It Up Up Pump It 5.4 Dynamic Objects 5.4 Dynamic Objects 128 David T. Chen system of six second-order differential equations. To create a dynobj that can handle simple rigid body dynamics, one would type at the 3d prompt, 3d> dyncreate 6 rigidbody rigidbody 3d> 1s rigidbody - string s vector s vector s vector .dyn-xddot x xddot xdot where .dyn.xddot is a str that contains the name of the Tcl derivs function that evaluates xddot for rigidbody. The command defined by .dyn-xddot is in essence a Callback function (as used extensively in the X Window System) that defines the second-order ODE system for the dynamic object, and is automatically invoked as many times as required by LSODE when a simulation step is taken by the command dynstep. It is important to note that the vectors x, xdot and xddot are easily accessed by the matrix commands of the previous section. Because a dynobj is created as a directory structure, it is easy to augment with data types specific to a dynamic situation to be simulated. For example, the solution to the FEM equilibrium equations can be written . = M-'(R - Kx - C.) which indicates that m2ds for the stiffness matrix K, the damping matrix C and for the mass matrix M must be added to the directory rigidbody in addition to another vnd for the external force. Of course the .dyn-xddot Callback must also be modified to solve the FEM equations. A partial listing of the dynamic object commands follows, It Up Up Pump It 5.4 5.4 Dynamic Objects Dynamic Objects 129 David T. Chen dyncreate noeqns d dyninit d [sparse] dynstep stepsize d dyntime [new-t] d dyntol [rtol atoll d dynmethod [meth] d dyneqs [no.eqs] d lsodedebug [level] 5.5 -- make a dynamic object flag integrator for restart forward simulate current simulation time relative and absolute error tolerance 10 is Adams-Basthforth [see lsode srcl get/set number of equations to be solved set/get lsode debug level User Interface The Tcl language was originally written to be integrated with the widget library of a window system, and can serve two purposes in such a context. These are to configure the actions of an application's interface, and to design the appearance of that interface. Tcl is used for both purposes by 3d. The widget set used is OSF/Motifrm and the windowing system is HP's port of X. The user interface is currently defined by three kinds of dialog - through the keyboard, through interactive Dialog Boxes or direct mouse manipulation of objects inside the graphics window. Figure 5.2 shows the primary Motif dialog box used in 3d. 5.5.1 Motif Widgets Most of the Motif constructors have been imported as application-specific commands into 3d. These commands have a very uniform calling sequence as in XmCreateScale parent name args no -- returns new widget which creates a slider widget. When such a widget is constructed, a hexadecimal pointer address is returned that can be parsed by the other X/Motif interpreter commands. Motif resources can be accessed as documented in [Fou90] and [You90]. Actions are defined through the X Callback mechanism. A Callback can be any 3d command or tclproc. As Pump It Up 5.5 User Interface David T. Chen 130 130 David T. Chen * Vjec Ilse*e Li Render Render ... Orfent Viwv H1wo Simulate 10 S. Rat.... .. jct fltp Iterations Current Danmic .1 Step Sire We adleRat .mm-wwwm.......... v Look~t Object Figure 5.2: 3d dialog box Pump It Up 5.5 User Interface 131 David T. Chen a simple example, a small program that creates a PushButton with a simple Callback is presented. This code relies on the tciproc Xmap that allows simple list passing of up to 32 arguments to a widget constructor. proc Xmap { func parent name arglist } { set args [argcreate 32] set no 0 foreach i $arglist { XtSetArg $no [index $i 0] [index $i 1] $args set no [plus 1 $no] } set widget [$func $parent $name $args $no] free $args return $widget } As with all Xt programs, the Toolkit must be initialized before widgets can be created. A RowColumn widget is made as a child of the Toplevel shell, and a PushButton is made that reads "Push Me". The string "Yow!" is echoed when the button is pushed. set top [XtInit Test {}] set widget [XmCreateRowColumn $top {} {} 0] Xmap XmCreatePushButtonGadget $widget {} { {labelString { Push Me }} {activateCallback {echo Yow!}} } XtRealize $top 5.5.2 X Events The X mouse and window events are also available to 3d. Callbacks can be setup on a window to listen for mouse clicks, keyboard presses, cursor motion and resize events. The Callback function is handed a list that contains the event information as its argument. In It Up mp It Pu Pump Up 5.5 User Interface 5.5 User Interface 132 David T. Chen the following example, a window is made and mouse button pushes are requested. In this case, the Callback simply echos the EventList as it is received. set top [XtInit Test {}] set widget [Xmap XmCreateForm $top {} {{width 250} {height 250}}] XtRealize $top set win [XtWindow $widget] EventCallback $win 5 { echo } 5.6 User-Assisted Finite Element Mesh Construction An example interactive application written using the 3d system is a user-assisted FEM mesh generator. Totally automatic mesh generation is non-trivial, and is especially hard for a full 3D case [Cha88] [CB89]. Here, the approach taken to this problem is to provide the user with an interactive tool that allows simple construction of finite element meshes that fill a volume defined by polyhedral objects. No effort was made to calculate error indicators that could quantify the quality of the generated mesh as done in [CB89], but in general, a better mesh is produced by using more elements and adaptively fitting the elements to capture the details of the goal geometry. A mesh constructed with the technique implemented in the thesis can be of arbitrary size, but the larger the number of elements used, the slower the dynamics will run. These kind of tradeoffs are discussed in Chapter 3. In fact, it is easy to design a mesh too big for the current simulation system. The dialog box created for the mesh generation process is shown in Figure 5.3. The steps to make a finite element mesh for the polyhedral Cyberware head model from Section 2.3.1 will be presented. The element used is the twenty-node brick discussed in Section 3.2. For the purposes of computer animation, it is sufficient to coarsely sample the head with only three isoparametric cubes, one for the shoulders, one for the neck and Pump It Up 5.6 User-Assisted Finite Element Mesh Construction David T. Chen 133 133 David T. Chen E1 $hrlinkt i i i Si1 hoj Fi gure 5.3: FEM mesh dialog b oix Ox Pump It Up 5.6 User-Assisted Finite Element Mesh Construction 134 David T. Chen one for the rest of the head. In this arrangement, two element faces are shared, so the number of degrees of freedom to be simulated will be 3* (3*20 - 2*8) = 132. The starting point for the mesh generation process is to fill the volume defined by the bounding box of the Cyberware model with the number of elements set in the Mesh text area of the dialog box, see Figure 5.4. Figure 5.4: Mesh filing Cyberware head bounding box The z axis is chosen to represent the natural orientation of the object. In this direction, there are seven contour levels defined by the nodal point z values. These contour levels can be easily adjusted through the interface of Figure 5.3. For the Cyberware head, levels two and four are moved so that the middle isoparametric brick encompasses the neck area. The Snap push-button recenters the edge midpoints after the element corners are shifted. This intermediate mesh is shown in Figure 5.5. The points of the mesh are then cylindrically shrinkwrapped around the z axis to Pump It Up 5.6 User-Assisted Finite Element Mesh Construction David T. Chen 135 135 David T. Chen Figure 5.5: Mesh boundaries interactively shifted intersect the polygonal object. This is done by calculating a contour from the points of the polyhedral data for each z level and drawing the outside mesh points in to intersect the contour. This produces the finite element approximation to the Cyberware head. Because the mesh points can initially be relatively distant from the polyhedral model, the procedure is done in two stages. First, the mesh is shrunken only to the bounding boxes defined by the local contours with the toBbox push-button. Then the intersection with the contour defined by the geometry data is done. The mesh after shrinkwrapping to the local bounding boxes is shown in Figure 5.6. After shrinking, it is necessary to recenter those element midpoints that make a concave edge with SnapConcave, or else a malformed stiffness matrix K may be found as described in [Bat82]. After the finite element approximation has been completed, the mesh information can either be saved to disk, or simulation parameters can be set for running dynamic trials. Pump It Up 5.6 User-Assisted Finite Element Mesh Construction David T. Chen 136 136 David T. Chen Figure 5.6: Mesh shrunken to head The parameters Young's modulus E, Poison's ratio v, and the mass density p can be fixed identically for each of the constituent elements, or else set individually to model an inhomogeneous composite material. A dynobj is then constructed by calculating the matrices K and M and by performing the modal transformation as in Chapter 3. Furthermore, the polyhedral head is embedded in the isoparametric mesh by performing the local to natural coordinate transformation described in Section 3.2.2. To test the behavior of the finite element model, the Modal dialog box of Figure 3.10 is used to examine the mode-shape deformations defined by the eigenvectors 4; as in Figure 5.7. This simple mesh construction tool was written in approximately 320 lines of Tcl code. An additional 550 lines were needed for the X interface. Application-specific routines written in C were also added to 3d to calculate the shrinkwrapping contours from the input obj and to shrink the mesh points as required, and to do the element midpoint recentering Pump It Up 5.6 User-Assisted Finite Element Mesh Construction David T. Chen 137 137 David T. Chen Figure 5.7: Head warped through mode-shape deformation operations described. In total, with the existing C libraries, these routines took only about 600 new lines to implement. 5.7 Validating the FEM Implementation Before proceeding further, an attempt is made to validate the FEM implementation by comparing simulation results to the analytic solution for an idealized beam. In the next chapter, a similar set of trials will be run to validate the biomechanical implementation by reproducing some of the experiments done on whole muscle that lead to the development of Zajac's muscle model. The problem to be considered is a simple beam subjected to a uniform gravity force. The beam is 6 inches long, 2 inches high and 2 inches wide. The beam is made to have the Pump It Up 5.7 Validating the FEM Implementation David T. Chen 138 density of water, which in the English units is .00112287 slugs/in 3 , and so weighs .868 lbs on Earth. The acceleration of the Earth's gravity is -386 in/s 2 . The other physical parameters to set are the mechanical material properties of the beam. For a linear, homogeneous, isotropic material, this is done in terms of E and v. E is Young's modulus and is simply the ratio of stress to strain. The Young's modulus chosen here is 435.11 psi, which approximates some kinds of rubber. For comparison, steel has modulus of elasticity E = 3 x 107 psi. Poisson's ratio, v, is the ratio of lateral contraction to longitudinal extension and so is a dimensionless quantity. A value of v = .5 is used for materials that are volume preserving. The Poisson's ratio for steel ranges from 0.25 to 0.33, for rubber it is slightly less than 0.50 [Har49]. Note that a look back to Equation 3.3 indicates that a Poisson's ratio of exactly 0.50 will cause a divide by zero and so is not possible. Volume preserving materials are then approximated with v close to, but not equal to 0.50. Initially, the beam is undeflected with no loading. At time 0, gravity is turned on and the beam deforms in response. The solutions for the deflection of cantilever beams under various loading conditions are well known. Analytic formulations from [Har49] are used as the control for this experiment. These solutions are based on the assumption that the cross-sectional dimensions are small compared with the beam's length. Consider the beam in Figure 5.8 subjected to a uniform load w all along its length 1. At a point x, which is distance I - x from the free end, the bending moment is w(l - x) 2 /2. The deflection at the free end is written, W1 4 = Y=l = 8E1 For a beam with rectangular cross-section, I is given by 3 I bh 12 where b is the width and h the height of the cross-section. In this case, b = h = 2 and so Pump It Up 5.7 Validating the FEM Implementation 139 David T. Chen i 4 Figure 5.8: Uniformly loaded cantilever beam. adaptedfrom [Den Hartog] The load w is simply the force per cross-sectional slice of the beam, and is found by calculating the total force due to gravity and dividing by the length of the beam. The total mass is 24 x .00112287 = .02694888 slugs, w = -386 x .02694888/6 = 1.73371128 lb And so the analytic solution for the amount of deflection at the tip of the beam is, 6= 1.73371128 * 64 8 * 435.11 * 1.3333 - . .484121076 in For experiment, two different finite element discretizations of the beam are simulated, one with three elements and the second with six elements. The particular element used is the twenty-node isoparametric brick discussed in Section 3.2. After matrix assembling, the three element beam has 44 nodes and 132 degrees of freedom. The six element beam has 80 nodes and 240 degrees of freedom. The effect of mode truncation is examined by performing a number of trials with different numbers of modes for each beam. Figure 5.9 plots the eigenvalues for the two beams. Pump It Up 5.7 Validating the FEM Implementation 140 David T. Chen 140 David T. Chen 2. 10 1.5 10 8 8 1. 10 5. 10 Figure 5.9: Plot of eigenvalues for 3 and 6 element beams. 3 element plot is dashed, 6 element plot is solid For the three element beam, three separate simulation trials are run for the deflection, once with 30 modes, once with 100 modes, and finally with all 132 modes. The tabulated statistics are, the total number of steps taken by the LSODE integrator for half a second of total simulation, the number of derivs function evaluations needed, the total real time required for the simulation, and the beam deflection at time .5 seconds. no. of modes frac. of total LSODE steps 30 100 132 .227 .758 1. 16791 16904 16695 func. evals. 30356 30681 30244 evals. per step 1.81 1.82 1.81 simulation deflection (inches) time (mins) .3046 45 .4351 63 .4493 70 percent error 37 10 7.2 Table 5.1: Runtime and tip deflection for 3 element beam. As expected, the error for the deflection goes down as the number of modes increases. Also note that the FEM results are all stiffer, or represent an upper-bound to the analytically predicted results. The time course of the tip deflection is plotted in Figure 5.10. For the second trial, a six element beam is used instead of the three element beam. Pump It Up 5.7 Validating the FEM Implementation David T. Chen 141 141 David T. Chen -0 .1 ---- --0. -0 .5 -0.6 Figure 5.10: Deflection for 3 element beam. Length vs. time. 30 mode plot is dotted, 100 mode plot is dashed and 132 mode plot is solid. The same behavior as regards the number of modes is expected, but the final results should better approximate the analytic deflection values. no. of modes frac. of total LSODE steps func. evals. evals. per step simulation time deflection (inches) percent error (mins) 30 54 100 182 240 .125 .225 .417 .758 1. 16073 15716 17047 17191 23142 28996 28311 30996 31306 24635 1.80 1.80 1.82 1.82 1.06 56 61 90 119 117 .3304 .4035 .4525 .4792 .4881 32 17 6.5 1.0 .82 Table 5.2: Runtime and tip deflection for 6 element beam. Again, the final deflection is better approximated by the simulation with the most modes. The deflection for this case is plotted in Figure 5.11. The cost in calculating the derivs function for this problem is dominated by the matrix multiplications for the modal forces, Rmodal = qTR, and updating the nodal positions, u = 4x, as discussed in Section 3.4.4. For the three element beam, 4 has rank 132 and the Pump It Up 5.7 Validating the FEM Implementation 142 David T. Chen 142 David T. Chen -0.1 -0.2 -0.3 -0.5 -0.6 Figure 5.11: Deflection for 6 element beam. Length vs. time. 54 mode plot is dotted, 182 mode plot is dashed and 240 mode plot is solid. matrix multiplies take about .023 seconds each. For the six element beam, <P has rank 240 and the large matrix multiplies take roughly .081 seconds each. The initial and final states for the 6 element beam used in the experiment are shown in Figure 5.12 and Figure 5.13. Pump It Up 5.7 Validating the FEM Implementation 143 143 David T. Chen David T. Chen Figure 5.12: Beam made from 6 twenty-node elements, initial state Figure 5.13: Beam made from 6 twenty-node elements, final state Pump It Up 5.7 Validating the FEM Implementation David T. Chen 144 Chapter 6 Methods and Results 6.1 Frog Gastrocnemius Simulation Models that simulate the action of muscle on a wide variety of levels have been proposed for a wide variety of purposes; the model that is implemented clearly depends on the desired objective. For instance, much research is being done to investigate the fundamental physical and chemical mechanisms of the actin-myosin crossbridge attachments within muscle fibers. Individual fibers can be extracted from frogs, subjected to periodic displacement changes and the visco-elastic properties measured as in [CGT86] and [JBDT88]. For this research, Blang6 and Stienen have proposed a model of single muscle fibers as an infinitesimally thin rod composed of a repeating sequence of springs and damping elements, see Figure 6.1. Alternately, engineers who design artificial limbs to improve or replace lost motor function often make calculations of muscle force based on kinematic body movements and on measured EMG activity. This kind of muscle model was discussed in Section 4.2 in reference to the work of Wood. Zajac in [ZTS86] and [Zaj89] discusses a dimensionless musculotendon model that Pump It Up Methods and Results 145 David T. Chen sarcomeres Figure 6.1: Model of single muscle fiber is a refinement of the classic Hill model, appropriate for studies of intermuscular coordination. Details of my implementation of this model can be found in Section 2.2.3. Delp in [De190] -uses Zajac's muscle functions in a surgical simulation system that calculates the static effects of tendon transfer surgery. When human limbs are impaired, motor function can sometimes be recovered through surgical reconstruction. These reconstructions, however, often compromise the capacity of muscles to generate the amount of force needed to coordinate natural body activity. Surgeons typically rely on experience to make decisions about a given procedure. Delp has created a tool that can pre-operatively evaluate the effect of a procedure on muscle function. The result is that the computer model can assist in understanding the biomechanics of a reconstructive surgery. Computer graphics is an essential part of computer models for surgery simulation or BioCAD systems--both to visualize the 3D musculoskelatal geometry and to facilitate communication between engineer and surgeon. Pump It Up 6.1 Frog Gastrocnemius Simulation 146 David T. Chen When doing computer animation, we are primarily interested in simulation for the purpose of automatically generating changes in shape and position. A major supposition of this thesis is that in the case of graphically simulating a contracting muscle, it is possible to produce convincing shape changes by accurately simulating the forces involved. Furthermore, through simulation we will be able to analyze which elements of the muscle model are important factors in determining the shape. A natural application for such a model would be in a surgical simulator such as the one developed by Delp. A major difference between the muscle model proposed here and the ones discussed above is that our's must be truly 3-dimensional to make computer animations of human characters. Other muscle models are essentially one-dimensional-Delp used simple straight lines to visualize the muscle origin and insertion points. Clearly a 3D model is a requirement for computer graphics, but we will also see that there may be biomechanical advantages because of the extra complexity and realism of the model. Because our goal requires us to model a complex, dynamic, irregular, elastic volume, the underlying formulation is based on the finite element method discussed at length in Chapter 3. In that chapter, we discussed how to make linear deformable visco-elastic models from data represented polyhedrally, how forces can be applied to the node points of the resulting FEM mesh, and how to forward simulate these models through the use of numerical differential equation solvers. In this way, we argue that we have met the twin goals of computer animation and creating a biomechanically valid simulation of muscle. 6.1.1 Force-based Finite Element Muscle Model The muscle model was constructed by dissecting the gastrocnemius from an anesthetized frog, measuring the top and side dimensions, then Swivel was used to make a polyhedral model with 576 polygons, see Section 2.3. The user-assisted finite element mesh generator Pump It Up 6.1 Frog Gastrocnemius Simulation 147 David T. Chen described in Section 5.6 was then used to interactively construct the mesh shown in Figure 6.2. Four twenty-node isoparametric bricks are used to approximate the gastrocnemius. The exact number of elements used represents a tradeoff of the quality of the simulation versus simulation time as discussed in Section 5.6. The model then has 56 nodes or 168 total degrees of freedom. Figure 6.2: Finite element mesh used for frog gastrocnemius To simulate a contraction, force generators are added to the node points of the finite element mesh that act along the longitudinal direction of the muscle. Wired in this way, there are eight generators per twenty-node brick, for a total of 32 for the whole muscle. Tendons are constructed in a similar fashion, see Figure 6.3. To facilitate the simulation, the dynobj data structure from Section 5.4 is augmented with information for the muscle state. Using the notation of Section 5.4, for the muscle fibers, we add Pump It Up 6.1 Frog Gastrocnemius Simulation 148 David T. Chen tendon force generator 20 node finite element , active & passive muscle force generator I * I I * I a I I I I I I Figure 6.3: Force generators for muscle and tendon Pump It Up 6.1 Frog Gastrocnemius Simulation 149 David T. Chen 1. fibers, integer vector vni, of length (nofibers*2): encodes which nodes are attached 2. f iber-lenO, double vector vnd, of length (nofibers): fiber rest length 3. fiberilen, double vector vnd, of length (nofibers): current fiber length 4. f iber-time, string str: simulation time for which f iber-len was calculated In addition, three other str parameters define the muscle, as per Zajac's dimensionless model. The maximum isometric active force is f iber.-FOa, the passive force scalar is f iberFOp and the maximum normalized fiber velocity is f iberVmax. To calculate the force within each of the muscle fibers to be applied to the finite element mesh nodal points in the derivs function, an application-specific routine muscle-zajacF was added to 3d, muscle-zajacF F0a FOp Vmax wspF d -- Add active and passive muscle force to 'wspF' using Zajac model which accepts the maximum active and passive forces and the maximum normalized fiber velocity as inputs. The world space force vector wspF (R(t) from Section 3.4.4) for the dynamic object d is accumulated with the muscle fiber forces. These fiber forces are calculated by muscle.zajacF as follows. For the four element approximation to the frog gastrocnemius in Figure 6.2, named gastroc, the fibers are numbered, 3d> m2dump /gastroc/fibers 0 16 1 17 2 18 3 19 16 4 17 5 18 6 19 7 20 28 21 29 22 30 23 31 28 0 29 1 30 2 3 1 3 32 40 33 41 34 42 35 43 40 20 41 21 42 22 43 23 44 52 45 53 46 54 47 55 52 3 2 53 33 54 34 55 35 where nodes {0 16} define the first muscle fiber, {1 17} the second, and so on. Pump It Up 6.1 Frog Gastrocnemius Simulation 150 David T. Chen The current world space mesh nodal positions are found for each fiber. These are subtracted to yield a world space length. From this the normalized fiber length IM is, lm = len / vnd-get( fiber-lenO, i ); The normalized length is used to find the isometric active and passive force functions, and their derivatives, as discussed in Section 2.2.3, zajac.passiveforce( lm, &Fmp, &dFm ); zajac-activeforce( lm, &Fma, &dFm ); The fiber velocity is determined through the following first-order approximation. Before the next call to dynstep, the lengths for each of the muscle fibers are found and saved in f iber-len. The simulation time before the next call to dynstep is stored in f iber-time. When dynstep is then used to take the next step, the instantaneous simulation time is accessed by muscle-zajacF as DynObjectGetTime( d, &time ); and the normalized velocity i; if computed, (time == fibertime) velocity = 0.; else { velocity = (len - vnd-get(fiber-len,i)) / (time - fiber-time); velocity /= vndget( fiber-len0, i ); velocity / Vmax; from which the scale factor from the force-velocity curve is looked-up, zajac-forcevelocity( velocity, &Fvc ); and the force generated by the fiber from the normalized quantities is, Pump It Up 6.1 Frog Gastrocnemius Simulation 151 David T. Chen = Fmp * FOp; force += Fma * FOa * Fvc; force *= .5; force The final scale by .5 is done because half the force is applied to the first node point of the fiber, and the other half of the force is summed with the second fiber node point. If the world space vector that defines the fiber orientation is dl, and inl and in2 are the two fiber indices, then the world space fiber force is accumulated into wspF as, VVAscale( dl, force ); vnd-setplus( wspF, in1*3 + 0, d1[O] ); vnd.setplus( wspF, in1*3 + 1, d1[1] ); vnd-setplus( wspF, in1*3 + 2, d1[2] ); vnd-setplus( wspF, in2*3 + 0, -d1[O] ); vnd.setplus( wspF, in2*3 + 1, -d1[1] ); vnd-setplus( wspF, in2*3 + 2, -dl[2] ); The tendon fibers are modeled in much the same way as the muscle fibers, the main difference being that tendons connect mesh node points to external world space locations. For tendon, the dynobj data structure is further augmented with, 1. tendons, integer vector vni, of length (notendons): encodes which nodes are tendon attached 2. tendon-lenO, double vector vnd, of length (notendons): the tendon rest length 3. tendon-wsppt, double vector vnd, of length (notendons*3): the world space attachment points 4. tendon-force, double vector vnd, of length (notendons*3): the amount of force generated by the tendon fibers Pump It Up 6.1 Frog Gastrocnemius Simulation 152 David T. Chen There is also a str that scales the normalized tendon force, tendonFO. The force generated by each of the tendon fibers, is found by the application-specific routine tendon-zaj acF. tendon-zajacF FO wspF d -- Add tendon force to 'wspF' using Zajac model which accumulates the tendon fiber forces into the world space force vector wspF. These forces are calculated by tendon-zajacF as below. For the four element approximation, gastroc, the tendon fibers are placed at the edge midpoints of the bottom and top faces of the mesh assemblage, 3d> m2dump /gastroc/tendons 49 51 48 50 13 15 12 14 0 3 11 20 23 27 32 35 39 To calculate the tendon force, begin with the world space location of the node to which the tendon fiber is fixed. Subtract the position of the external attachment point defined by tendonwsppt, and find the length len and direction of the resulting vector dl. Using the rest length of the current tendon fiber, the strain ET is, strain = (len - lenO) / lenO; Then the strain is used to look up the normalized tendon force. The vector dl is scaled by the force, zajac-tendonforce( strain, &Ft, &dFt ); force = Ft * FOt; This is repeated for each tendon fiber and again the computed force is summed into the world space external force vector wspF for the finite element mesh. In addition, the force generated by each of the tendon fibers is saved in the vector tendon-force. This is because the total force generated by the muscle is the sum of the reaction forces created Pump It Up 6.1 Frog Gastrocnemius Simulation 153 David T. Chen by the tendon attachments. This total force is, of course, an important measure and is one the quantities plotted in the subsequent experiments. The two application-specific routines muscle-zajacF and tendon-zajacF are invoked by the standard derivs function in 3d for the modally transformed finite element equations. The name of the Callback function that defines the effect of the muscle and tendon fibers is set within the gastroc structure, sset $d/.dyn-forces muscle-contract and the .dynforces Callback is invoked within derivs as foreach f [sset $d/.dyn.forces] { eval $f $wspF $d } where the Tcl procedure muscle-contract is proc muscle-contract { wspF d } { set Foa [mult [sset $d/fiberFOa] [sset $d/.activation]] set FOp Esset $d/fiberFOp] set Vmax [sset $d/fiberVmax] set FOt [sset $d/tendonFO] muscle-zajacF $Fa $FOp $Vmax $wspF $d tendon-zajacF $FOt $wspF $d } The effects of the muscle activation function a(t), directly scales the maximum active fiber force f iberFOa. This is the mechanism used to turn the muscle on and off. To test the biomechanical validity of the muscle model developed here, two well-known experiments are simulated. First, tension-length curves will be plotted of both active and relaxed muscle. Second, Gasser and Hill's quick-release experiment will be simulated to reveal the dynamic time course of the forces generated by the finite element muscle model. Pump It Up 6.1 Frog Gastrocnemius Simulation David T. Chen 6.1.2 154 Tension-Length Experiment The first experiment plots the characteristic tension-length relationship produced by the FEM muscle model. This is easy to do by attaching the top set of tendons to various positions to control the overall muscle length, measuring the amount of force generated by the whole muscle, then fully activating the muscle and measuring the force again. The setup for this experiment is illustrated in Figure 6.4. The muscle is attached with tendon to both the bone and the horseshoe shaped "clamp" in the figure. Figure 6.4: Setup for tension-length experiment Up to now, most of the development has concerned computing the non-linear muscle force functions defined by biomechanical models to apply at the finite element mesh nodal points. To fully specify the FEM model, however, the passive mechanical characteristics of muscle must also be set. Grieve and Armstrong in [GA88] publish stress-strain curves Pump It Up 6.1 Frog Gastrocnemius Simulation 155 David T. Chen derived from compressing plugs taken from pig muscle. These curves are also non-linear, the plugs becoming stiffer the more they are compressed. The range of values for Young's modulus they present are from close to 0 up to 2.745 x 103 Pa at a strain of 40%. Or, in cgs units, 2.745 x 104 dyne/cm2 A major assumption made in the thesis, is that in terms of these passive elastic properties, muscle can be approximated as a linear, homogeneous, isotropic material. This assumption is necessary because of simplifications inherent in the derivation of the stiffness matrix in Section 3.1.1, but could be easily relaxed by implementing better constitutive models [Bat82]. In any case, I feel this simplification is justified when examining muscle contraction because the contraction forces are orders of magnitude larger than the passive mechanical forces, and these non-linear, anisotropic forces are indeed modeled. An intermediate, convenient value is then chosen for E. Poisson's ratio, v, is set to approximate a volume preserving material. The density, p, of muscle was found by Grieve and Armstrong through careful weighing. Gravity, g, is turned off so as not to confound the force measurements. The physical constants for the simulation are as follows, E = 1000 dyne/cm 2 v = .49 p = 1.04 g/cm3 g = 0 cm/s 2 The frog muscle rest length is 6 cm long. The maximum isometric force generated by the gastrocnemius measured in the frog lab (Section 2.3), was 2.77 N or 2.77 x 105 dynes. This force is distributed evenly among the 32 fibers and so the fiber force is 8656.2 dynes. The tension-length experiment is performed by first measuring the force for the passive muscle. This is done by examining the force generated in the tendons attached to the clamp through the tendon-force vector. The muscle is activated and the force measured again. The whole process is repeated for the muscle set to different initial lengths. The resulting tension-length curves are presented in Figure 6.5. An examination of this plot shows a good correspondence to the published biological Pump It Up 6.1 Frog Gastrocnemius Simulation 156 David T. Chen 156 David T. Chen 400oo0 200000 ';' lo0000 0.6 0.8 1 1.2 1.4 1.6 Figure 6.5: Simulation results for tension-length experiment. Isometric muscle force vs. normalized length. Dotted line is total isometric force, dashed line is the force from passive muscle and the solid line is the developed force. observations (see Figure 2.10), with a local maximum for the muscle at its rest length. The other result taken from this simulation, interesting from the point of view of computer graphics, is that very little changes in shape are produced by a muscle undergoing purely isometric contraction. Another of the simplifying assumptions made in the muscle model is that all the fibers are homogeneous both in terms of the amount of force they can develop, and in their response to stimulus from the neural controller (u(t) in Figure 2.37). The small observed shape change is then expected since the actions of all the series and parallel fibers should produce a net zero resultant force at the internal mesh faces, while producing a large force at the origin and insertion ends which is then cancelled by the tendon forces. Hence, to produce larger shape changes for the purposes of computer animation requires either the muscle to lengthen or shorten, or for the contraction to work against shape changes due to external forces such as gravity. Pump It Up 6.1 Frog Gastrocnemius Simulation David T. Chen 6.1.3 157 Quick Release Experiment The second experiment simulated is the quick release procedure carried out by Gasser and Hill to examine the velocity dependent effects within the muscle. The muscle is stimulated and made to work isometrically. Then the muscle is suddenly released and hits a 'knot' or new position constraint after a certain amount of time. A plot of force versus time for this experiment is presented in Figure 6.6. The muscle begins at the rest length, 6 cm or IM = 1. The amount of shortening that takes place is 1.3 cm so that the final normalized IM muscle length is 0 7833. Force 6 4- 2- 50 100 150 -2- -4 - Figure 6.6: Simulation results for Gasser-Hill quick release experiment. Force is scaled to match plot of Figure 2.12. Force vs. time. Figure 6.6 shows a good correspondence with Gasser and Hill's plots of Section 2.2.2. In that section, the conclusion drawn from the shape of the curves is that the slow rise in the force both when the muscle is activated, and after the quick release, indicate that it is caused by a biochemical damping effect, rather than a central nervous system control mechanism. Furthermore, I feel the shape of this force function justifies another of the simplifying assumptions made in the model, namely that the effects of excitation-contraction dynamics (see Figure 2.37) are negligible for this application because they occur on a much shorter time scale than what is being simulated. Pump It Up 6.1 Frog Gastrocnemius Simulation 158 David T. Chen The original intent was to model the velocity-dependent damping characteristics of muscle through setting the Rayleigh parameters of the FEM equations as in Section 3.4.1. However, because the fiber forces are so much larger than the internal forces produced by the passive visco-elastic material, this approach caused the numerical integrator (LSODE from Section 5.4) to fail. The importance of including this damping is illustrated by the following example. As discussed above, a change of shape in the simulated muscle is only predicted for a situation in which the contraction works against shape changes produced by external forces. Such a case is presented in Figure 6.7, in which the relaxed frog muscle bows downwards due to gravity. Upon contraction, the muscle pulls taut between its attachment points. If however, velocity dependent effects are not included, or the maximum velocity, ~4E, is set too high, the muscle will oscillate back and forth, much as a plucked string, in an amusing, albeit unrealistic manner. The arrows in the figure show the direction, but not the scale, of the world space forces acting at the finite element mesh node points. 6.1.4 Human Gastrocnemius Simulation The FEM based muscle model is used in a similar way to simulate contraction of the medial gastrocnemius from a human subject, the polyhedral data for which is presented in Section 2.3. This muscle is approximated with a four element mesh made of twenty-node bricks as in the frog simulations. The medial gastrocnemius model is 24 cm long. The maximum isometric force used is 1113 N from Delp. Each of the 32 fibers generates 34.78 N or 3.48 x 106 dynes. The passive mechanical parameters for the FEM mesh are set as before, E = 2000 dyne/cm 2 v = .49 p = 1.04 g/cm 3 g = -980 cm/s 2 To model fascia attachments to the rest of the leg, tendons are defined for nodes on Pump It Up 6.1 Frog Gastrocnemius Simulation David T. Chen 159 159 David T. Chen Figure 6.7: Relaxed muscle deforms due to gravity. Active muscle pulled taut. Pump It Up 6.1 Frog Gastrocnemius Simulation 160 David T. Chen the backside of the muscle. These are set so that the muscle can move freely, but not by a large amount. Furthermore, a reaction constraint (see Section 4.3) is defined so that the muscle will not penetrate the soleus. For the animation, the leg is rotated 45 degrees to horizontal and the relaxed muscle deforms due to gravity. Figure 6.8 shows that muscle contraction causes the gastrocnemius to pull taut as expected. Again, the arrows only show the direction in which the world space forces are acting. Pump It Up 6.1 Frog Gastrocnemius Simulation David T. Chen 161 161 David T. Chen Figure 6.8: Human gastrocnemius deformed due to gravity, then pulled taut. Pump It Up 6.1 Frog Gastrocnemius Simulation 162 David T. Chen 6.1.5 Future Work Besides net force, the second quantity measured in both frog experiments was the volume of the finite element mesh throughout the stages of the simulation. For a twenty-node isoparametric cube, the volume is easy to compute by performing a numerical gauss integrationof the determinant of the Jacobian matrix as discussed in Section 3.2. Plots are presented of the normalized volume, equal to the current volume divided by the rest volume in Figure 6.9 for the tension-length experiment, and in Figure 6.10 for the quick-release experiment. The rest volume of the gastrocnemius is 1.054 cm3 . Vol 0.6- - 0.4- 0.2- - I 0.6 I 0.8 I 1.2 I 1.4 I Lt n 1.6 Figure 6.9: Simulation results for tension-length experiment. Normalized element volume vs. length. Solid line is volume for passive stretch, dashed line is for active muscle. Even though Poisson's ratio was specified to approximate a volume preserving material, Figure 6.9 indicates this criterion for a muscle was not met; the likely reason being the small-strain approximation that was made in solving for the stiffness matrix K (see Section 3.1.1). To do a large-strain analysis requires both more complicated strain measures and more complicated constitutive relationships than those developed here [Bat82]. As a temporary workaround to this problem, a simple volume constraint was implemented that applies an instantaneous first-order correction to the mesh volume. Figure 6.11 shows the effect of this correction for the tension-length experiment. Pump It Up 6.1 Frog Gastrocnemius Simulation 163 David T. Chen it ~.-. 0.4+ T1M,- Figure 6.10: Simulation results for quick-release experiment. Normalized element volume vs. time. II4M M -- o Or-". 0.8 0.6 0.4 0.2 0.6 0.8 1.2 1.4 1.6 Figure 6.11: Simulation results for tension-length experiment with volume constraint. Normalized element volume vs. length. Solid line is volume for passive stretch with constraint. Dashed line is passive stretch without constraint. Pump It Up 6.1 Frog Gastrocnemius Simulation 164 David T. Chen We mentioned that another of the simplifying assumptions made in the muscle model is that all of the fibers are homogeneous in terms of the amount of force they can develop. The final experiment done using the frog gastrocnemius model examines the effect of simulated fiber force inhomogeneities on the total force produced. Here the force exerted by an individual fiber is scaled by the local volume measured by the containing finite element. Thus, the wider elements, which represent local volumes with greater physiologic cross-section (see Section 2.2) will produce more force than the fibers within the thinner elements at the tendon ends. The tension-length experiment was then repeated and the results plotted in Figure 6.12. The shape of the plot indicates inefficiencies of muscle function caused by uneven fiber lengths. The fibers within the thinner elements become overly stretched and are not able to produce as much force as they otherwise would. The resulting tension-length curve also does not exhibit the local maximum predicted by Zajac's model. This force inefficiency manifested itself in an interesting redistribution of the muscle mass in which a change of shape is produced even for an isometric case. Though I am convinced that the results from this simulation are accurate in terms of the forces and changes in shape produced, at this time, no claim is made that real muscles exhibit this behavior. But, it does seem like a reasonable phenomena that might bear looking into. What this experiment does reveal is the kinds of investigations involving nonuniform fiber effects that can be performed with the FEM model developed in the thesis. Other experiments to try include staggering the activation pattern across the muscle, or varying the fiber length and orientation through the muscle. Pump It Up 6.1 Frog Gastrocnemius Simulation David T. Chen 165 165 David T. Chen 200000 100000 *0 0.1 0.8 0.9 1 X/ 1.1 1.2 1.3 Figure 6.12: Simulation results for tension-length experiment with fiber inhomogeneities. Isometric muscle force vs. normalized length. Dotted line is total isometric force, dashed line is the force from passive muscle and the solid line is the developed force. Pump It Up 6.1 Frog Gastrocnemius Simulation 166 David T. Chen 6.2 Computer Animation 6.2.1 Using the FEM for Computer Animation Physical simulation has only in the past four or five years been utilized as a way of generating computer animation. As a form of engineering analysis, however, it has had a long and varied history. The displacement based finite element method that we have been exploring here at the Computer Graphics and Animation Group to simulate the physics of deformable objects has its beginnings in the early 1950's. Since then there has been a large amount of cross-disciplinary research and a very large number of publications on the subject. While it is possible to create very realistic looking keyframe animations by using splines [Las87], this is often hard and tedious. To meet the goals of computer animation, physical simulation can provide a mechanism for automatically generating complex motions and changes in shape. The reason the FEM was chosen as the underlying formulation for the muscle model is that our goals include not only geometric visualization, but also building computational models that can be simulated and used to predict the behavior of real structures. In this way, the methods developed to allow fast graphical visualization and forms of interactive manipulation can carry over to interesting applications such as the surgery simulation systems presented by Delp [De190] and Pieper [Pie92]. To do the thesis work, a software system 2d (see Chapter 5) was written that can dynamically model elastically deformable objects based on the finite element method. The effects that can be employed include simulation of rigid body motion, simulation of deformation, collision with arbitrary polyhedrally represented objects, friction, and constraint satisfaction. An effort has been made to find solutions algorithmically and numerically suitable for graphics workstations. Both for computer animation and simulation environments, we would like to be able Pump It Up 6.2 Computer Animation 167 David T. Chen to use familiar geometric representations-polygon and spline based patch descriptions-as rendering vehicles. On the other hand, the dynamic simulations that have been discussed are calculated based on a finite element mesh. A finite element implementation built on isoparametric elements can be used to target both of these functions. Like the free-form deformations described by Sederburg [SP86], a method has been developed in which the twenty-node isoparametric brick defines a free-form deformation that can be used to warp the points of polyhedral or patch objects very easily. Furthermore, the twenty-node brick is an extremely effective element on which to build a 3D finite element implementation and is widely used in engineering analysis. To define assemblies of meshes based on polyhedral data, a user-assisted mesh generator has been written. The principle of virtual work is used to derive the stiffness and mass matrices that govern the dynamic behavior of the mesh. The modal transformation is performed to the matrix equations so that the differential equations defining the dynamic response can be more quickly and effectively solved. Mode truncation bandlimits the frequency response of the dynamic system resulting in fewer problems with stiff input forces. Reaction constraints as presented by Platt [PB88] have been extended for use in the FEM framework so that forces that match the goals of computer animators can be easily defined. Two example computer animations are presented to illustrate using the finite element method to make animations of elastically deformable objects with controlled motions. 6.2.2 Jell-O @ Dynamics An animation is created of a visco-elastic cube of "Jello" discretized by eight twenty-node brick elements. The Jello has length 2 cm on a side. The geometric polyhedral model is a cube made with 100 polygons per face. All told, the geometry is defined by 602 points and 600 polygons. Though papers have been published regarding the optical properties of Pump It Up 6.2 Computer Animation 168 David T. Chen Jello [Hec87], no one has yet examined its material properties (other than to say it wiggles). Jello is made mostly of water and so is assumed to be largely incompressible, and to have the density of water. For now, Young's modulus is chosen solely on the basis of the final appearance of the animation. E = 1000 dyne/cm 2 v = .49 p = 1 g/cm 3 g = -980 cm/s 2 The other objects in the scene are a funnel, a grid floor and a cutcube "rock". The initial conditions are such that the Jello begins off screen, above the funnel with zero velocity. The simulation begins, gravity causes the Jello to fall into the funnel, hit the cutcube rocks and drop off the grid floor. The funnel opening is set so that the Jello will have to squeeze and wiggle its way out. Collision constraints for the Jello are set for the grid and cutcube. The funnel rendered in the final animation is double-sided and so is inappropriate for the collision analysis algorithm implemented here. Thus a collision "stand-in" object is used to define the constraint for the funnel. Figure 6.13 shows the Jello falling through the funnel stand-in. Figure 6.14 is a finished software rendered scene, complete with transparency, lighting, and shadow effects. Pump It Up 6.2 Computer Animation 169 David T. Chen 169 David T. Chen Figure 6.13: Jello motion Figure 6.14: Scene from finished Jello animation Pump It Up 6.2 Computer Animation 170 David T. Chen 6.2.3 GED Puff A computer animation is made of a "Puff" character bouncing across the floor. The polyhedral Puff object was created by Steve Strassman and made its first appearance in the award-winning short GrinningEvil Death by Mikey McKenna and Bob Sabiston. The Puff is discretized with three twenty-node brick elements. The Puff motion is created through the action of constraints. A small (30 line) program was written to kinematically control the up, down, and twisting motion of a rigid skeleton. The Puff is tied to the skeleton by reaction constraints at four of the mesh nodal points. A constraint is also used to make a collision with the grid floor. In this case, all simulation parameters are chosen for the sake of the final animation, and so that the computation time is minimized. E = 20 dyne/cm 2 Pump It Up v = .3 p = .1 g/cm 3 g = -1 cm/s 2 6.2 Computer Animation David T. Chen 171 Figure 6.15: Blooby Puff bounce Pump It Up 6.2 Computer Animation David T. Chen 172 Chapter 7 Conclusions For computer animation, the next step beyond kinematic simulations of skeleton movement must include realistic modeling and rendering of the muscle and skin. A finite element model of muscle has been developed that can be used both to simulate muscle forces and to visualize the dynamics of muscle contraction. Biomechanically, we have taken an existing model of muscle function from Zajac, added complexity by making it 3D, and shown that under certain circumstances it still behaves like a muscle. We have tried to validate the model by doing biomechanical experiments and plotting out key quantities. It is much harder to validate the shape changes produced by the force-based FEM muscle model. Videos of live frog and human subjects have been made to serve as checkpoints for the simulations, but these can do so only qualitatively. The clearest way to verify the shape changes produced by the muscle model would be to make a whole series of MRI reconstructions, with the limb held in different states of isometric tension while measuring the muscle force wherever possible. A series of reconstructions made in this way would be appropriate data against which to compare simulation results. This would be a big project, and just barely doable with the current MRI technology. Pump It Up Conclusions David T. Chen 173 However, by emphasizing the physical model, I think we have taken a step beyond the original computer graphics goal of making a virtual actor, up to the goal of making an artificialperson. By studying the anatomy, the form will be revealed through the function. KU 19. ~ AN"M .W 40 Ih >t *W'Wi ONP 8-1 The Motra Museum ofFneAt Conclusions Pump Pump It It Up Up Conclusions David T. Chen 174 Acknowledgements I dedicate this thesis to my parents, who supported and encouraged me through the years, to my brother and sister, to my wife Betsy and our daughter Darcy for providing love and comfort, and to all the guys in the SnakePit, especially Stevie and Mikey, for making this such a fun and worthwhile experience. Thanks, of course, go to many, many people, starting with my advisor, David Zeltzer for creating the Computer Graphics and Animation Group and starting me off on this research problem. The story of how muscles work is one of the most fascinating topics there is. The members of my thesis committee, Joe Rosen who gave up so much of his time, John Williams and Steve Benton all provided invaluable vision and encouragement. Special thanks go to Simon Gitzer for sharing with me his experience and understanding of muscle function. And thanks to everyone else, without whom I never would have finished, David Sturman, Steve Drucker, Tinsley Galyean, Margaret Minsky, Peter Schroeder, Mike Halle, Linda Peterson, walter, lacsap, hank, march, eman, ferdi, kenji, mat, bconn, brian, alex, irfan, sclaroff, kk, shigeru, janette, judith, gitta, jh, klug, barons, ken, leo, lpeeps, yoshi, russ, . . . Conclusions Pump It It Up Up Conclusions David T. Chen David T. Chen 175 175 Bibliography [AD85] M. L. Audu and D. T. Davy. The influence of muscle model complexity in musculoskeletal motion modeling. Journal of Biomechanical Engineering,107:147157, 1985. [AG85] William W. Armstrong and Mark Green. The dynamics of articulated rigid bodies for purposes of animation. Proceedings, Graphics Interface '85, pages 407-415, 1985. [Bat82] Klaus-Jiirgen Bathe. Prentice-Hall, 1982. [BC89] Armin Bruderlin and Thomas W. Calvert. Goal-directed, dynamic animation of human walking. A CM Computer Graphics, 23(3):233-242, 1989. [BOT79] N.I. Badler, J. O'Rourke, and H. Toltzis. A spherical representation of a human body for visualizing movement. Proceedings IEEE, 67(10):1397-1402, October 1979. [CB89] Soo-Won Chae and Klaus-Jiirgen Bathe. On automatic mesh construction and mesh refinement in finite element analysis. Computers & Structures, 32(3/4):911-936, 1989. [CGT86] G. Cecchi, P.J. Griffiths, and S. Taylor. Stiffness and force in activated frog skeletal muscle fibers. Biophysical Journal,49:437-451, 1986. [Cha88] Soo-Won Chae. On the Automatic Generation of Near-Optimal Meshes for Three-Dimensional Linear-ElasticFinite Element Analysis. PhD thesis, Massachusetts Institute of Technology, 1988. [CHP89] John E. Chadwick, David R. Haumann, and Richard E. Parent. Layered construction for deformable animated characters. ACM Computer Graphics, 23(3):243-252, 1989. [CW74] F. D. Carlson and D. R. Wilkie. Muscle Physiology. Prentice-Hall, Inc., 1974. PUMPItup Finite Element Procedures in Engineering Analysis. BIBLIOGRAPHY 176 David T. Chen [De190] Scott L. Delp. Surgery Simulation: A Computer Graphics System to Analyze and Design Musculoskeletal Reconstructions of the Lower Limb. PhD thesis, Stanford University, 1990. [Fea87] Roy Featherstone. Robot Dynamics Algorithms. Kluwer Academic Publishers, 1987. [Fet82] William A. Fetter. A progression of human figures simulated by computer graphics. IEEE Computer Graphics and Applications, pages 9-13, November 1982. [Fou90] Open Software Foundation. OSF/MotifTM Programmer'sReference. PrenticeHall, Inc., 1990. [GA88] Andrew P. Grieve and Cecil G. Armstrong. Compressive properties of soft tissues. In G. de Groot, A. P. Hollander, P. A. Huijing, and G. J. van Ingen Schenau, editors, Biomechanics XI-A, International Series on Biomechanics, Amsterdam, 1988. Free Unversity Press. [GH24] H.S. Gasser and A.V. Hill. The dynamics of mucular contraction. Royal Society of London Proceedings,96:398-437, 1924. [GMTT89] Jean-Paul Gourret, Nadia Magnenat-Thalman, and Daniel Thalman. Simulation of object and human skin deformations in a grasping task. A CM Computer Graphics, 24(3):21-30, 1989. [Har49] J.P. Den Hartog. Strength of Materials. Dover Publications, 1949. [Hat76] H. Hatze. The complete optimization of the human motion. Mathematical Biosciences, 28:99-135, 1976. [Hec87] Paul S. Heckbert. Ray tracing jell-o@ brand gelatin. A CM Computer Graphics, 21(4):73-74, 1987. [HH54] H. Huxley and J. Hanson. Changes in the cross-striations of muscle during contraction and stretch and their structural interpretation. Nature, 173:973976, 1954. [HN54] A.F Huxley and R. Niedergerke. Structural changes in muscle during contraction. Nature, 173:971-973, 1954. [JBDT88] D.W.G Jung, T. Blang6, H. DeGraaf, and B.W. Treijtel. Elastic properties of relaxed, activated and rigor muscle fibers measured with microsecond resolution. Biophysical Journal,54:897-908, 1988. Up Pu mp It It Up Pump BIBLIOGRAPHY BIBLIOGRAPHY 177 David T. Chen [Joh9l] Michael Boyle Johnson. Build-a-Dude: Action selection networks for computational autonomous agents. Master's thesis, Massachusetts Institute of Technology, 1991. [Kel7l] David L. Kelley. Kinesiology: Fundamentals of Motion Description. Prentice Hall, Inc., 1971. [Kom86] Koji Komatsu. Human skin model capable of natural shape variation. Laboratories Note 329, NHK, Tokyo, March 1986. [Las87) John Lasseter. Principles of traditional animation applied to 3d computer animation. ACM Computer Graphics, 21(4):35-44, 1987. [LC87] W.E. Lorensen and H.E. Cline. Marching cubes: A high resolution 3d surface construction algorithm. ACM Computer Graphics, 21(4):163-169, 1987. [Lot84] Per Lotstedt. Numerical simulation of time-dependent contact and friction problems in rigid body mechanics. SIAM Journal of Scientific Statistical Computing, 5(2), 1984. [LW27] A. Levin and J. Wyman. The viscous elastic properties of muscle. Royal Society of London Proceedings, 101:218-243, 1927. [Max83] Delle Rae Maxwell. Graphical marionette: a modern-day Pinocchio. Master's thesis, Massachusetts Institute of Technology, 1983. [McK90] Michael McKenna. A dynamic model of locomotion for computer animation. Master's thesis, Massachusetts Institute of Technology, 1990. [McM84] Thomas A. McMahon. Muscles, Reflexes, and Locomotion. Princeton University Press, 1984. [MhLH90] S. McKenna, Y. harvill, A. Louie, and D. Huffman. Swivel 3D Professional User's Guide. Paracomp, Inc., 1987-1990. [MW88] Matthew Moore and Jane Wilhelms. Collision detection and response for computer animation. A CM Computer Graphics, 22(4):289-298, 1988. [Ous9O] J.K. Ousterhout. Tcl: An embeddable command language. USENIX Conference Proceedings,1990. [Pau81] Richard P. Paul. Robot Manipulators: Mathematics, Programmingand Control. The MIT Press, Cambridge, Massachusetts, 1981. [PB88] John C. Platt and Alan H. Barr. Constraint methods for physical models. A CM Computer Graphics, 22(4):279-288, 1988. Pump It Up 1990 Winter BIBLIOGRAPHY David T. Chen 178 [PFTV88] William H. Press, Brian P. Flannery, Saul A. Teukolsky, and William T. Vetterling. Numerical Recipes in C. Cambridge University Press, 1988. [Pie90] Steven Donald Pieper. More than skin deep: Physical modeling of facial tissue. Master's thesis, Massachusetts Institute of Technology, 1990. [Pie92] Steven Donald Pieper. CAPS: Computer-Aided Plastic Surgery. PhD thesis, Massachusetts Institute of Technology, 1992. [Pla89] John Platt. Constraint Methods for Neural Networks and Computer Graphics. PhD thesis, California Institute of Technology, April 1989. Department of Computer Science, Caltech-CS-TR-89-07. [PMSM81] A.G. Patriarco, R.W. Mann, S.R. Simaon, and J.M. Mansour. An evaluation of the approaches of optimization models in the prediction of muscle forces during human gait. Journal of Biomechanics, 14(8):513-525, 1981. [PW89] Alex Pentland and John Williams. Good vibrations: Modal dynamics for graphics and animation. A CM Computer Graphics, 23(3):215-222, 1989. [Rib82] Eric Alan Ribble. Synthesis of human skeletal motion and the design of a special-purpose processor for real-time animation of human and animal figure motion. Master's thesis, Ohio State University, 1982. [Roc83] K. C. Rockey. The Finite Element Method: A Basic Introduction. Wiley, 2 edition, 1983. [Smi84] Alvy Ray Smith. The viewing transformation. Technical report, Computer Graphics Project, Computer Division, Lucasfilm Ltd., Marin, California, May 1984. [SP86] Thomas W. Sederberg and Scott R. Parry. Free-form deformation of solid geometric models. ACM Computer Graphics, 20(4):151-160, 1986. [Str9l] Steven Henry Strassmann. Desktop Theater: Automatic Generation of Expressive Animation. PhD thesis, Massachusetts Institute of Technology, 1991. [SZ90] Peter Schr6der and David Zeltzer. The virtual erector set. ACM Computer Graphics, 24(2):23-32, 1990. [TF88] Demetri Terzopoulos and Kurt Fleischer. Modeling inelastic deformation: Viscoelasticity, plasticity, fracture. A CM Computer Graphics, 22(4):269-278, 1988. [VSL75] Arthur J. Vander, James H. Sherman, and Dorothy S. Luciano. Human Physiology - The Mechanisms of Body Function. McGraw Hill, 1975. It Up Up Pump It BIBLIOGRAPHY BIBLIOGRAPHY 179 David T. Chen [Wil56] D. R. Wilkie. Measurement of the series elastic component at various times during a single muscle twitch. Journal Physiology, 134:527-530, 1956. [Wil87] Jane Wilhelms. Using dynamic analysis for realistic animation of articulated bodies. IEEE Computer Graphics and Applications, pages 12-27, June 1987. [Wil90] Lance Williams. 3d paint. A CM Computer Graphics, 24(2):225-233, 1990. [WMJ89] J.E. Wood, S.G. Meek, and S.C. Jacobsen. Quantization of human shoulder anatomy for prosthetic arm control, part i. Journal of Biomechanics, page 273, 1989. [Woo76] John Everett Wood. Theoretical Formalismfor the Kinesiological Trajectories of a Computer Simulated Neuro-Musculo-Skeletal System. PhD thesis, Massachusetts Institue of Technology, 1976. [You90] Douglas A. Young. The X Window System@ Programming and Applications with Xt: OSF/Motif@ Edition. Prentice-Hall, Inc., 1987-1990. [Zaj89] F. E. Zajac. Muscle and tendon: Properties, models, scaling, and application to biomechanics and motor control. Critical Reviews in Biomedical Engineering, 17:359-411, 1989. [Zel84] David Zeltzer. Representation and Control of Three Dimensional Computer Animated Figures. PhD thesis, Ohio State University, 1984. [ZPS89] D. Zeltzer, S. Pieper, and D. Sturman. An integrated graphical simulation platform. Proc. Graphics Interface '89, 134:266-274, June 1989. [ZTS86] F. E. Zajac, E.L. Topp, and P.J. Stevenson. A dimensionless musculotendon model. Proceedings IEEE Engineering in Medicine and Biology, 1986. Pump It Up BIBLIOGRAPHY 180 David T. Chen 180 David T. Chen Appendix A Isoparametric Interpolation The following is a C implementation of the blending functions for a 20 node isoparametric cube element. * dead~media-lab 02/20/90 c20-map.c * * c20_nodes array added by stevie 9/13/90 *include <stdio.h> #include <math.h> #ifndef lint static char copyright[] = "Copyright (c) 1989, 1990 by David T. Chen. #endif 10 All rights reserved."; typedef int VectorI[3]; typedef float Vector[3]; typedef float Matrix[4][4]; typedef double (*PFD)(); static VectorI UNIT-NODES[20] {0, 1, 1}, {0, 1, -1}, Up Pu mp ItIt Up Pump {-1, 0, 1}, {-1, 0, -11, 20 = {0, -1, {0, -1, 1}, -1}, {1, 0, 1}, {1, 0, -1}, Isoparametric Interpolation Isoparametric Interpolation 181 David T. Chen 181 David T. Chen {1, 1, 0}, * * * {1, -1, 0} {-1, -1, 0}, {-1, 1, 0}, c20_nodes: Pointer to an array of node pointers. If the node pointer is null, correponding interpolation -Stevie 9/13/90 functions will not be included. static char **c20-nodes = NULL; #define c20_node-exists(i) ((c20-nodes) ? (c20nodes[(i)]) : ((char *)1)) c20_node-seLarray(nodes) char **nodes; { c20_nodes = nodes; } functions Interpolation dGO G(, ) beta-i beta, G( double static beta; double beta.i; int { double ans; if 0) == (beta.i ans else if (beta-i == 1) else if (beta.i == -1) = = .5 = ans * (beta - 1. ans * .5 beta); (1 + (1 * beta); - beta); else { stderr, fprintf( ans ans return( "G: bad beta-i <Xd>\n", betai ); 0.; = ); static double dG( beta, beta_i double beta; ) int beta..i; { double ans; if (beta-i == 0) ans = -2. * beta; else if (betai == 1) ans = .5; else if (beta-i == -1) ans = -. 5; else { fprintf( stderr, "dG: bad beta-i <%d>\n", beta-i ); ans = 0.; Pump It Up Isoparametric Interpolation 182 David T. Chen return( ans } 80 Function g and the partials with respect to r, s, t go, dgdr(), dgds(, dgdt( static double g( r, s, t, i double r, s, t; int i; ) { double ans; 90 i < 0) return( 0. ); if (i > 19 if ( !c20_node-exists(i) ) return( 0. ); ans =G( r, UNIT-NODES[i][0] ans =G( s, UNITNODES[i][1] ans *= G( t, UNITNODES[i][2] return( ans ); ); ); } 100 static double dgdr( r, s, t, i double r, s, t; ) int i; { double ans; if (i > 19 || i < 0) return( 0. ); if ( !c20_node-exists(i) ) return( 0. ); dG( r, UNIT-NODES[i][0] ans= 110 ); G( s, UNIT-NODES[i][1] ); ans ans *= G( t, UNIT-NODES[i][2] ); return( ans } static double dgds( r, s, t, i double r, s, t; ) int i; { double ans; 120 if (i > 19 || i < 0) return( 0. ); if ( !c20_node-exists(i) ) return( 0. ); ans ans ans Pump It Up = G( r, UNITNODES[i][0] ); dG( s, UNITNODES[][1] ); G( t, UNITNODES[i][2] ); Isoparametric Interpolation 183 David T. Chen18 David Chen T. return( ans ); static double dgdt( r, s, t, i double r, s, t; ) int i; { double ans; if (i > 19 || i < 0) return( 0. ); if ( !c20-node-exists(i) ) return( 0. ); ans *= ans *= ); G( r, UNITNODES[i][0] = ans G( s, UNIT-NODES[i][1] ); dG( t, UNIT-NODES[i][2] ); return( ans ); h Function the and partials with to respect r, s, t c20_h(, c20_dhdro, c20_dhdso, c20_dhdt() c20_h-BLEND( double static r, double s, r, s, t, i, name, g ) t; i; int char *name; PFD g; { double ans; (i.> 19 || Zi< 0) fpri'ntf( stderr, return( 0. ); "Xs: bad i <Xd>\n", name, i ) ans = (*g)(r,s,t,i'); if (i, = = 0) {ans += -. 5 * ((*g)(r,s, t,8) + (*g)(r, s, t,11) + (*g)(r,s, t,16)); else if (iZ=' {ans += 1 -. 5 * ((*g)(r,s,t,8) + (*g)(r,s,t,9) + (*g)(r,s,t,17)); else if (i == 2) {ans += -. 5 * ((*g)(r, s, t,9) + (*g)(r,s, t,10) + (*g)(r,, t,18)); else if (==3) {ans += -. 5 * ((*g)(r,s, t,10) + (*g)(r,s, t,11) + (*g)(r,s,t,19)); else if (i == 4) Pump It Up Isoparametric Interpolation 184 David T. Chen 184 David T. Chen { ans += -. 5 * ((*g)(r,s,t,12) + (*g)(r,s,t,15) + (*g)(r,s,t,16)); I else if (i == 5) { ans += -. 5 * ((*g)(r,s,t,12) + (*g)(r,s,t,13) + (*g)(r,s,t,17)); } else if (i == 6) { ans += -. 5 * ((*g)(r,s,t,13) + (*g)(r,s,t,14) + (*g)(r,s,t,18)); } else if (i == 7) { ans += -. 5 * ((*g)(r,s,t,14) + (*g)(r,s,t,15) + (*g)(r,s,t,19)); return( ans ); double c20_h( r, s, t, i double r, s, t; ) int i; { return( c20_h-BLEND(r, s, t, i, "c20_h", g) ); } double c20_dhdr( r, s, t, i double r, s, t; ) 200 int i; { return( c20_h-BLEND(r, s, t, i, "c20_dhdr", dgdr) ); } double c20-dhds( r, s, t, i) double r, s, t; int i; { return( c20_hBLEND(r, s, t, i, "c20_dhds", dgds) ); double c20_dhdt( r, s, t, i ) double r, s, t; int i; { return( c20-hBLEND(r, s, t, i, "c20_dhdt", dgdt) ); } Coordinate transformation from natural to local space. Input twenty nodal points and an array of natural coordinate points. Output points in local space. 'num' is array length. c20_Natural2Local( node-points, natural, local, num Vector *node-points, *natural, *local; ) int num; { int i, j; double r, s, t, Z, y, z, h; Pump It Up Isoparametric Interpolation 220 185 David T. Chen (i=O; i<num; i++) r = natural[i][0]; s = natural[i][1]; t = natural[i][2]; x = y = z = 0.; j++) { h = c20-h( r, s, t,j); x += h * node-points[j[0); for (j=0; j<20; y += h * node-points[j][1]; z += h * node-points[j][2]; local[i][0] = x; local[i][1] = y; local[i][2] = z; Pump It Up Isoparametric Interpolation David T. Chen 186 186 David T. Chen Appendix B Fast Interpolation The following is a C implementation of the blending functions for a 20 node isoparametric cube element. * c20-fast.c deadqmedia-lab 02/20/90 * * * Interpolate through a 20 node isoparametric cube. Math from stevie and Mathematica typedef float Vector[3]; c20_X() double c20_X( C, r, s, t double *C, r, s, t; ) { double r2, s2, t2, ans; r2 = r*r; s2 = s*s; t2 = t*t; + ans= C[O] C[1] * r * s + C[2] * s * t2 + C[3] * r * s * t2 + C[4] * r * t2 + C[5] * r * s * t It Up Pump It Up Fast Interpolation Fast Interpolation David T. Chen 187 C[6] * t2 C[8] * r2 * s C[1o] C[12] C[14] C[16] C[18] * r2 * s2 * t * s2 * r * s2 + C[7] + C[9] * r2 * t + C[11] + C[13] + C[15] + C[17] + C[19] * s * t * r2 * s * t t r r * s2 * t t; * r * * * * return( ans ); double c20_dXdr( C, r, s, t double * C, r, s, t; I double r2, s2, t2, ans; r2 = 2 * r; r = s2 = 1.; s * s; t2 = ans = C[1] + C(4] + C[7] + C[9] + C[13] + C[17] t * t; r *8 + C[3] * r * r2 * * r2 * s * t r * s * + C[2] + C[5] * s + C[9] * r2 *s t + C[12] + C[16] + C[18] * s2 t * r * s2 * t * t2 s Sr + C[8] + C[10] + C[15] + C[18] t *r * + C[5] t2 * r2 * t s * r2 * r *r *s2; 50 return( ans ); double c20-dXds( C, r, s, t double * C, r, s, t; ) { double r2, s2, t2, ans; s2 = 2 * s; s = 1.; r2 = r * r; t2 = t t; ans = C[1] + + + + + C[3] C[8] C[11] C[14] C[17] * r * * r2 * *S r * t2 t * s2 * s * * s2 * t s * Sr * r t2 s* S t * t * s2; return( ans ); double c20_dXdt( C, r, 8, t double *C, r, s, t; d double r2, Pump Pump It It Up Up 82, 12, ) ans; Fast Interpolation Fast Interpolation David T. Chen 188 188 David T. Chen t2 = 2 * t; t = 1.; r2 = r * r; s2 = s * s; ans = C[2] C[4] C[6] C[9] C[13] C[17] + + + + + s * t2 r * t2 t2 r2 r * r * s * t2 C[3] r s * t C[5] C[7] * r2 * t t C[11] *s C[14] * s2 * t C[19] * t; s * t * t r * s2 * t return( ans ); c20_make-polynomial() c20-make-polynomial( nodes, index, C Vector *nodes; ) int index; double C[]; C[o] = - 0.25*nodes[0][index] 0.25*nodes[2][index] 0.25*nodes[4][index] 0.25*nodes[6][index] -- 0.25*nodes[1][index] -- 0.25*nodes[3][index] -- 0.25*nodes[5][index] 0.25*nodes[7][index] + + + + + + 0.25*nodes[8][index] F 0.25*nodes[9][index] 0.25*nodes[10][index] + 0.25*nodes[11][index] 0.25*nodes[12][index] + 0.25*nodes[13][index] 0.25*nodes[14][index] + 0.25*nodes[15][index] 0.25*nodes[16][index] + 0.25*nodes[17][index] 0.25*nodes[18][index] + 0.25*nodes[19][index]; -- C[1] = 0.25*nodes[16][index] - 0.25*nodes[11][index] + 0.25*nodes[18][index] - 0.25*nodes[19][index]; C[2] = 0.125*nodes[0][index] + 0.125* nodes [1] [index] - 0.125*nodes[2][index] - 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0.125*nodes [5] [index] - 0.125*nodes[6][index] 0.25*nodes[16][index] - 0.125*nodes[71[index] 0.25*nodes[17][index] + 0.25*nodes[18][index] + 0.25*nodes[19][index]; C[3] = 0.125*nodes[0][index] - 0.125*nodes[1][index] + 0.125*nodes[21[index] - 0.125*nodes[3][index] Up Pump It It Up Fast Interpolation Fast Interpolation 189 David T. Chen 189 David T. Chen 0.125*nodes[4][index] 0.125*nodes[6][index] 0.25*nodes[16][index] + 0.25* nodes [18] [index] + 0.125*nodes[5][index] 0.125*nodes[7][index] 0.25*nodes[17][index] 0.25*nodes[19][index]; C[4] = 0.125*nodes[0][index] - 0.125*nodes[1][index] 0.25*nodes[17][index] 0.25*nodes[16][index] + + 0.25*nodes[18][index] - 0.125*nodes[2][index] + + 0.125*nodes[4][index] - 0.125*nodes[6][index] + - 0.25*nodes[19][index] 0.125*nodes[3][index] 0.125*nodes[5][index] 0.125*nodes[7][index]; C[5] = 0.125*nodes[0][index] - 0.125*nodes[1][index] + 0.125*nodes[2][index] - 0.125*nodes[3][index] - 0.125*nodes[4][index] + 0.125*nodes[5][index] - 0.125*nodes[6][index] + 0.125*nodes[7][index]; C[6] = 0.125*nodes[0][index] + 0.125*nodes[1][index] - 0.25*nodes[16][index] 0.25*nodes[18][index] - 0.25*nodes[17][index] 0.25*nodes[19][index] + 0.125*nodes[2][index] + 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0.125*nodes[5][index] + 0.125*nodes[6][index] + 0.125*nodes[7][index]; C[7] = 0.125*nodes[0][index] + 0.125*nodes[1][index] - 0.25*nodes[10][index] + 0.25*nodes[12][index] + 0.25*nodes[14][index] + 0.125*nodes[2][index] + 0.125*nodes[3][index] - 0.125*nodes[4][index] - 0.125*nodes[5][index] 0.125*nodes[7][index] - 0.125*nodes[6][index] 0.25*nodes[8][index]; C[8] = 0.125*nodes[0][index] + 0.125*nodes[1][index] + 0.25*nodes[10][index] - 0.25*nodes[12][index] + 0.25*nodes[14][index] - 0.125*nodes[2][index] - 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0.125*nodes[5][index] - 0.125*nodes[6][index] - 0.125* nodes[7][index] - 0.25*nodes[8][index]; C[9] = 0.125*nodes[0][index] + 0.125*nodes[1][index] + 0.25*nodes[10][index] + 0.25*nodes[12][index] 0.25*nodes[14][index] 0.125*nodes[3][index] 0.125*nodes[5][index] + + 0.125*nodes[7][index] - Pump ItIt Up Up 0.125*nodes[2][index] 0.125*nodes[4][index] 0.125*nodes[6][index] 0.25*nodes[8][index]; Fast Interpolation Fast Interpolation 190 190 David T. Chen David T. Chen C[10] = 0.125*nodes[0][index] + 0.125*nodes[1][index] - 0.25*nodes[10][index] - 0.25*nodes[12][index] 0.25*nodes[14][index] + 0.125*nodes[2][index] + 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0.125*nodes[5][index] + 0.125*nodes[6][index] + 0.125*nodes[7][index] - 0.25*nodes[8][index]; C[11] = -0.25*nodes[10][index] - 0.25*nodes[12][index] + 0.25*nodes[14][index] + 0.25*nodes[8][index]; C[12] = -0.125*nodes[0][index] - 0.125*nodes[1][index] - 0.25*nodes[10][index] + 0.25*nodes[12][index] - 0.25*nodes[14][index] + 0.25*nodes[16][index] + 0.25*nodes[17][index] - 0.25*nodes[18][index] - 0.25*nodes[19][index] + 0.125*nodes[2][index] + 0. 125*nodes[3][index] - 0.125*nodes[4][index] - 0. 125*nodes[5][index] + 0.125*nodes[6][index] + 0.125*nodes[7][index] + 0.25*nodes[8][index]; C[13] = 0.25*nodes[11][index] + 0.25*nodes[13][index] - 0.25*nodes[15][index] - 0.25*nodes[9][index]; C[14] = 0.125*nodes[0][index] + 0.125*nodes[1][index] - 0.25*nodes[11][index] + 0.25*nodes[13][index] + 0.25*nodes[15][index| + 0.125* nodes[2][index] + 0.125*nodes[3][index] - 0.125*nodes[4][index] - 0.125*nodes[5][index] 0.125*nodes[7][index] - 0.125*nodes[6][index] 0.25*nodes[9][index); C[15] = -0. 125*nodes[0][index] + 0.125*nodes[1][Index] + 0.25*nodes[11][index] - 0.25*nodes[13][index] + 0.25*nodes[15][index] + 0.25*nodes[1611:ndex] - 0.25*nodes[17][index] - 0.25*nodes[18][index] + 0.25*nodes[19][index] + 0.125*nodes[2][index] - 0. 125*nodes[3][index] - 0.125*nodes[4][index] + 0.125*nodes[5][index] + 0.125*nodes [6][index] - 0. 125*nodes[7][index] - 0.25*nodes[9][index]; C[16] = 0.125*nodes[0][index] + 0.125*nodes[1][index] - 0.25*nodes[11|[index] - 0.25*nodes[13][index] 0.25*nodes[15][index] + 0.125*nodes[2][index] + 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0.125*nodes[5][index] + 0.125*nodes[6][index] + 0.125*nodes[7][index] - 0.25*nodes[9][index]; Up It Up Pu mp It Pump Fast Interpolation Fast Interpolation 191 191 David T. Chen David T. Chen C[17] = 0.125*nodes[0][index] - 0.125*nodes[1][index] 0.25*nodes[11][index] 0.25*nodes[15][index] 0.125*nodes[3][index] - 0.25*nodes[13][index] 0.125*nodes[2][index] + 0.125*nodes[4][index] + + 0.125*nodes[6][index] + 0.125*nodes[5][index] - 0.125*nodes[7][index] + 0.25*nodes[9][index]; C[18| = 0.125*nodes[0][index] - 0. 125*nodes[1][index] - 0.25*nodes[11][index] + 0.25*nodes[13][index] - 0.25*nodes[15][index] - 0.125*nodes[2][index] + 0.125*nodes[3][index] + 0.125*nodes[4][index] - 0.125*nodes[5][index] - 0.125*nodes[6][index] + 0.125*nodes[7][index] + 0.25*nodes[9][index]; C[19] = -0.125*nodes [0][index] - 0.125*nodes[1][index] + 0.25*nodes[10][index] + 0.25*nodes[11][index] - 0.25*nodes[12][index| 0.25*nodes[14][index] 0.125*nodes[2][index] - 0.25*nodes[13][index] 0.25*nodes[15][index] 0.125*nodes[3][index] + 0.125*nodes[4][index] + 0. 125*nodes[5][index] + 0.125*nodes[6][index] + 0.125*nodes[7][index] + 0.25*nodes[8][index] + 0.25*nodes[9][index]; Pump It Up Fast Interpolation