Computer Animation Algorithms and Techniques
Rick Parent
Team LRN
Executive Editor Diane D. Cerra Publishing Services Manager Scott Norton Assistant Developmental Editor Belinda Breyer Editorial Assistant Ramona Buehler Cover Design Ross Carron Design Text Design Mark Ong, Side by Side Studios Supplementary Technical Illustration Tom Webster, LineWorks Composition Nancy Logan Copyeditor Sheila Berg Proofreader Karen Stough Indexer Ty Koontz Printer Courier Corporation Cover Images (from top): Detail of still from Geri’s Game, courtesy Pixar Studios; simulation of volcano spitting fire, courtesy Katie Boner and Barb Olsafsky; simulation of waves hitting shore, courtesy Arun Somasundaram; “Bragger in Beantown,” cour- tesy John Chadwick; robot, courtesy Jessica Hodgins; facial model, courtesy Scott King; driving simulation, courtesy Norm Badler Interior Images: Figures 5.26 and 5.27 (plates 4 and 5), courtesy David S. Ebert; Figure 5.28 (plate 6) courtesy Ruchir Gatha and David S. Ebert; figure 6.26, courtesy David S. Ebert; figures 6.28 and 6.31, courtesy Frederic I. Parke; figure 6.39, “Face and 2d Mesh,” reprinted from Signal Processing: Image Communication 15, nos. 4-5 (Tekalp, 2000): pp. 387-421, by permission of Elsevier Science; figure A.3 (plate 11), courtesy Disney Enterprises, Inc.; figure A.11 (plate 12), courtesy Pixar Studios, all rights reserved; figure A.12 (plate 13), courtesy Disney Enterprises, Inc.. The Random Number Generator discussed in appendix section B.5.3 is free software that can be redistributed and/or modified under the terms of the GNU Library General Public License as published by the Free Software Foundation. This library is distrib- uted free of charge but without warranty, even the implied warranties of merchantability or fitness for a particular purpose. For details, see the GNU Library General Public License posted at http://www.fsf.org/copyleft/library.txt. Designations used by companies to distinguish their products are often claimed as trademarks or registered trademarks. In all instances in which Morgan Kaufmann Publishers is aware of a claim, the product names appear in initial capital or all capital let- ters. Readers, however, should contact the appropriate companies for more complete information regarding trademarks and regis- tration. Morgan Kaufmann Publishers 340 Pine Street, Sixth Floor, San Francisco, CA 94104-3205, USA http://www.mkp.com ACADEMIC PRESS A Harcourt Science and Technology Company 525 B Street, Suite 1900, San Diego, CA 92101-4495, USA http://www.academicpress.com Academic Press Harcourt Place, 32 Jamestown Road, London, NW1 7BY, United Kingdom http://www.academicpress.com © 2002 by Academic Press All rights reserved Printed in the United States of America 06 05 04 03 02 5 4 3 2 1 No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means—elec- tronic, mechanical, photocopying, or otherwise—without the prior written permission of the publisher. Library of Congress Control Number: 2001090620 ISBN: 1-55860-579-7
This book is printed on acid-free paper.
Team LRN
To Mom and Dad
To John and Kim for teaching me to keep things in perspective
Team LRN Team LRN Foreword...... xv Preface ...... xvii Overview ...... xvii Organization of the Book ...... xx Acknowledgments ...... xxi References ...... xxii 1 Introduction ...... 1 Perception ...... 2 The Heritage of Animation ...... 4 Early Devices ...... 4 The Early Days of ˇConventional Animation...... 6 Disney ...... 7 Contributions of Others ...... 9 Other Media for Animation ...... 9 Principles of Computer Animation ...... 10 Animation Production ...... 12 Computer Animation Production Tasks ...... 15 Digital Editing ...... 17 Digital Video ...... 20 A Brief History of Computer Animation...... 21 Early Activity...... 21 The Middle Years ...... 24 Chapter Summary ...... 29 References ...... 29 Spaces and Transformations ...... 31 2 Technical Background ...... 31 The Display Pipeline...... 32 Homogeneous Coordinates and the Transformation Matrix ...... 36
Team LRN Compounding Transformations: Multiplying Transformation Matrices ...... 39 Basic Transformations ...... 40 Representing an Arbitrary Orientation ...... 42 Extracting Transformations from a Matrix ...... 45 Description of Transformations in the Display Pipeline ...... 46 Round-off Error Considerations...... 48 Orientation Representation ...... 51 Fixed Angle Representation ...... 53 Euler Angle Representation ...... 56 Angle and Axis ...... 57 Quaternions ...... 58 Chapter Summary ...... 61 References ...... 61 Interpolation ...... 63 3 Interpolation and Basic Techniques ...... 63 The Appropriate Function...... 64 Controlling the Motion Along a Curve ...... 68 Computing Arc Length...... 69 Speed Control ...... 84 Ease-in/Ease-out ...... 86 Constant Acceleration: Parabolic Ease-In/Ease-Out...... 89 General Distance-Time Functions...... 92 Curve Fitting to Position-Time Pairs...... 94 Interpolation of Rotations Represented by Quaternions ...... 97 Path Following ...... 102 Orientation along a Path...... 102 Smoothing a Path ...... 108 Determining a Path along a Surface ...... 114 Key-Frame Systems ...... 116 Animation Languages ...... 120
Team LRN Artist-Oriented Animation Languages ...... 121 Articulation Variables...... 122 Graphical Languages ...... 123 Actor-Based Animation Languages ...... 123 Deforming Objects...... 124 Warping an Object...... 125 Coordinate Grid Deformation ...... 125 Morphing (2D) ...... 143 Coordinate Grid Approach...... 143 Feature-Based Morphing...... 148 3D Shape Interpolation...... 153 Matching Topology ...... 157 Star-Shaped Polyhedra ...... 157 Axial Slices ...... 159 Map to Sphere...... 160 Recursive Subdivision ...... 166 Summary ...... 169 Chapter Summary ...... 169 References ...... 170 4 Advanced Algorithms...... 173 Automatic Camera Control ...... 174 Hierarchical Kinematic Modeling ...... 175 Representing Hierarchical Models ...... 177 Forward Kinematics...... 184 Local Coordinate Frames ...... 185 Inverse Kinematics ...... 192 Summary ...... 203 Rigid Body Simulation ...... 203 Bodies in Free Fall ...... 204 Bodies in Contact ...... 216 Enforcing Soft and Hard Constraints ...... 231 Flexible Objects ...... 232 Virtual Springs ...... 235 Energy Minimization ...... 236
Team LRN Space-Time Constraints...... 239 Controlling Groups of Objects ...... 241 Particle Systems...... 242 Flocking Behavior ...... 246 Autonomous Behavior ...... 257 Implicit Surfaces ...... 261 Basic Implicit Surface Formulation ...... 261 Animation Using Implicitly Defined Objects ...... 263 Collision Detection...... 264 Deforming the Implicit Surface as a Result of Collision...... 265 Summary ...... 267 Chapter Summary ...... 267 References ...... 268 5 Natural Phenomena ...... 271 Plants ...... 272 A Little Bit of Botany ...... 273 L-Systems ...... 275 Animating Plant Growth...... 280 Summary ...... 283 Water ...... 283 Still Waters and Small-Amplitude Waves ...... 284 The Anatomy of Waves ...... 288 Modeling Ocean Waves ...... 289 Finding Its Way Downhill ...... 292 Summary ...... 296 Gaseous Phenomena ...... 296 General Approaches to Modeling Gas ...... 296 Computational Fluid Dynamics...... 298 Clouds ...... 299 Fire ...... 310 Summary ...... 311 Chapter Summary ...... 312 References ...... 312
Team LRN 6 Modeling and Animating Articulated Figures ...... 317 Reaching and Grasping ...... 318 Modeling the Arm ...... 318 The Shoulder Joint ...... 321 The Hand...... 321 Coordinated Movement ...... 324 Reaching Around Obstacles...... 325 Strength ...... 326 Walking ...... 327 The Mechanics of Locomotion ...... 328 The Kinematics of the Walk...... 333 Using Dynamics to Help Produce Realistic Motion ...... 336 Forward Dynamic Control...... 338 Summary ...... 339 Facial Animation ...... 339 Types of Facial Models ...... 341 Creating the Model ...... 342 Textures ...... 345 Approaches to Animating the Face ...... 347 Overview of Virtual Human Representation ...... 353 Representing Body Geometry ...... 354 Geometry Data Acquisition...... 356 Geometry Deformation ...... 356 Clothing ...... 357 Hair ...... 357 Surface Detail ...... 358 Layered Approach to Human Figure Modeling ...... 358 Cloth and Clothing...... 361 Simple Draping ...... 362 Getting into Clothes ...... 365 Motion Capture ...... 369 Processing the Images ...... 371 Camera Calibration ...... 372 3D Position Reconstruction ...... 373 Fitting to the Skeleton...... 376
Team LRN Modifying Motion Capture ...... 378 Summary ...... 378 Chapter Summary ...... 379 References ...... 379 A Rendering Issues ...... 385 A.1 Double Buffering ...... 385 A.2 Compositing ...... 386 A.2.1 Compositing without Pixel Depth Information ...... 389 A.2.2 Compositing with Pixel Depth Information ...... 395 A.3 Displaying Moving Objects: Motion Blur ...... 398 A.4 Drop Shadows ...... 401 A.5 Summary...... 406 References ...... 406 B Background Information and Techniques ...... 409 B.1 Vectors and Matrices ...... 409 B.1.1 Inverse Matrix and Solving Linear Systems...... 411 B.1.2 Singular Value Decomposition ...... 419 B.2 Geometric Computations ...... 420 B.2.1 Components of a Vector ...... 420 B.2.2 Length of a Vector...... 420 B.2.3 Dot Product of Two Vectors ...... 420 B.2.4 Cross Product of Two Vectors ...... 422 B.2.5 Vector and Matrix Routines...... 424 B.2.6 Closest Point between Two Lines in Three-Space ...... 427 B.2.7 Area Calculations ...... 428 B.2.8 The Cosine Rule ...... 429 B.2.9 Barycentric Coordinates...... 430 B.2.10 Computing Bounding Shapes ...... 431 B.3 Transformations...... 447 B.3.1 Transforming a Point Using Vector-Matrix Multiplication...... 447
Team LRN B.3.2 Transforming a Vector Using Vector-Matrix Multiplication...... 448 B.3.3 Axis-Angle Rotations...... 449 B.3.4 Quaternions ...... 450 B.4 Interpolating and Approximating Curves ...... 453 B.4.1 Equations: Some Basic Terms...... 453 B.4.2 Simple Linear Interpolation: Geometric and Algebraic Forms ...... 454 B.4.3 Parameterization by Arc Length...... 456 B.4.4 Computing Derivatives ...... 456 B.4.5 Hermite Interpolation...... 457 B.4.6 Catmull-Rom Spline ...... 458 B.4.7 Four-Point Form...... 461 B.4.8 Blended Parabolas...... 462 B.4.9 Bezier Interpolation/Approximation ...... 463 B.4.10 De Casteljau Construction of Bezier Curves...... 464 B.4.11 Tension, Continuity, and Bias Control...... 465 B.4.12 B-Splines...... 467 B.4.13 Fitting Curves to a Given Set of Points ...... 469 B.5 Randomness...... 470 B.5.1 Noise ...... 471 B.5.2 Turbulence ...... 474 B.5.3 Random Number Generator ...... 474 B.6 Physics Primer ...... 476 B.6.1 Position, Velocity, and Acceleration...... 476 B.6.2 Circular Motion ...... 477 B.6.3 Newton