1 / 42

Marq Singer (marq@essentialmath)

Constrained Dynamics. Marq Singer (marq@essentialmath.com). The Problem. What are they Why do we care What are they good for. The Basics. Constraint – something that keeps an entity in the system from moving freely

duscha
Download Presentation

Marq Singer (marq@essentialmath)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Constrained Dynamics Marq Singer (marq@essentialmath.com)

  2. The Problem • What are they • Why do we care • What are they good for Essential Math for Games

  3. The Basics • Constraint – something that keeps an entity in the system from moving freely • For our purposes, we will treat each discreet entity as one particle in a system • Particles can be doors on hinges, bones in a skeleton, points on a piece of cloth, etc. Essential Math for Games

  4. Box Constraints • Simplest case • Movement constrained within a 2D area Essential Math for Games

  5. Box Constraints P 0 100 Essential Math for Games

  6. Box Constraints (cont) • Restrict P to extents of the box • Recover from violations in position (last valid, rebound, wrap around) • Simple, yet the basis for the rest of this Essential Math for Games

  7. Bead on a Wire • The Problem: • Restrict bead to path • Solutions: • Explicit (parametric) method • Implicit method Essential Math for Games

  8. Parametric Constraints Essential Math for Games

  9. Bead on a Wire • From Baraff, Witkin N = gradient f = force fc = constraint force f‘ = f + fc Essential Math for Games

  10. Implicit Representation legal position legal velocity legal acceleration Essential Math for Games

  11. Implicit Representation Constraint force = gradient vector times scalar l Essential Math for Games

  12. Spring Constraints • Seems like a reasonable choice for soft body dynamics (cloth) • In practice, not very useful • Unstable, quickly explodes Essential Math for Games

  13. Stiff Constraints • A special spring case does work • Ball and Stick/Tinkertoy • Particles stay a fixed distance apart • Basically an infinitely stiff spring • Simple • Not as prone to explode Essential Math for Games

  14. Cloth Simulation • Use stiff springs • Solving constraints by relaxation • Solve with a linear system Essential Math for Games

  15. Cloth Simulation Essential Math for Games

  16. Cloth Simulation • Forces on our cloth Essential Math for Games

  17. Cloth Simulation • Relaxation is simple • Infinitely rigid springs are stable • Predetermine Ci distance between particles • Apply forces (once per timestep) • Calculate D for two particles • If D != 0, move each particle half the distance • If n = 2, you’re done! Essential Math for Games

  18. Relaxation Methods Essential Math for Games

  19. Relaxation Methods Essential Math for Games

  20. Cloth Simulation • When n > 2, each particle’s movement influenced by multiple particles • Satisfying one constraint can invalidate another • Multiple iterations stabilize system converging to approximate constraints • Forces applied before iterations • Fixed timestep (critical) Essential Math for Games

  21. More Cloth Simulation • Use less rigid constraints • Vary the constraints in each direction (i.e. horizontal stronger than vertical) • Warp and weft constraints Essential Math for Games

  22. Still More Cloth Simulation • Sheer Springs Essential Math for Games

  23. Still More Cloth Simulation • Flex Springs Essential Math for Games

  24. Articulated Bodies • Pin Joints • Hinges Essential Math for Games

  25. Angular Constraints • Restrict the angle between particles • Results in a cone-shaped constraint Essential Math for Games

  26. Angular Constraints • Unilateral distance constraint • Only apply constraint in one direction Essential Math for Games

  27. Angular Constraints • Dot product constraint • Recovery is a bit more involved Essential Math for Games

  28. Stick Man • Uses points and hinges • Angular (not shown) allow realistic orientations • Graphic example of why I’m an engineer and not an artist Essential Math for Games

  29. Using A Linear System • Can sum up forces and constraints • Represent as system of linear equations • Solve using matrix methods Essential Math for Games

  30. Basic Stuff Systems of linear equations Where: A = matrix of coefficients x = column vector of variables b = column vector of solutions Essential Math for Games

  31. Basic Stuff • Populating matricies is a bit tricky, see [Boxerman] for a good example Isolating the ith equation: Essential Math for Games

  32. Jacobi Iteration Solve for xi (assume other entries in x unchanged): (Which is basically what we did a few slides back) Essential Math for Games

  33. Jacobi Iteration In matrix form: D, -L, -U are subparts of A D = diagonal -L = strictly lower triangular -U = strictly upper triangular Essential Math for Games

  34. Jacobi Iteration Definition (diagonal, strictly lower, strictly upper): A = D - L - U Essential Math for Games

  35. Gauss-Seidel Iteration Uses previous results as they are available Essential Math for Games

  36. Gauss-Seidel Iteration In matrix form: Essential Math for Games

  37. Gauss-Seidel Iteration • Components depend on previously computed components • Cannot solve simultaneously (unlike Jacobi) • Order dependant • If order changes the components of new iterates change Essential Math for Games

  38. Successive Over Relaxation (SOR) • Gauss-Seidel has convergence problems • SOR is a modification of Gauss-Seidel • Add a parameter to wG-S Essential Math for Games

  39. Successive Over Relaxation (SOR) • = a Gauss-Seidel iterate • 0 < w < 2 • If w = 1, simplifies to plain old Gauss-Seidel Essential Math for Games

  40. Gauss-Seidel Iteration In matrix form: Essential Math for Games

  41. Lots More Math(not covered here) • I highly recommend [Shewchuk 1994] • Steepest Descent • Conjugate Gradient • Newton’s Method (in some cases) • Hessian • Newton variants (Discreet, Quasi, Truncated) Essential Math for Games

  42. References • Boxerman, Eddy and Ascher, Uri, Decomposing Cloth, Eurographics/ACM SIGGRAPH Symposium on Computer Animation (2004) • Eberly, David, Game Physics, Morgan Kaufmann, 2003. • Jakobsen, Thomas, Advanced Character Physics, Gamasutra Game Physics Resource Guide • Mathews, John H. and Fink, Kurtis K., Numerical Methods Using Matlab, 4th Edition, Prentice-Hall 2004 • Shewchuk, Jonathan Richard, An Introduction to the Conjugate Gradient Method Without the Agonizing Pain, August 1994. http://www-2.cs.cmu.edu/~jrs/jrspapers.html • Witken, Andrew, David Baraff, Michael Kass, SIGGRAPH Course Notes, Physically Based Modeling, SIGGRAPH 2002. • Yu, David, The Physics That Brought Cel Damage to Life: A Case Study, GDC 2002 Essential Math for Games

More Related