Download presentation

Presentation is loading. Please wait.

1
Constrained Dynamics Marq Singer

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

3
Essential Math for Games 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.

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

5
Essential Math for Games Box Constraints P 100 0

6
Essential Math for Games 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

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

8
Essential Math for Games Parametric Constraints

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

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

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

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

13
Essential Math for Games 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

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

15
Essential Math for Games Cloth Simulation

16
Essential Math for Games Cloth Simulation Forces on our cloth

17
Essential Math for Games Cloth Simulation Relaxation is simple Infinitely rigid springs are stable 1.Predetermine C i distance between particles 2.Apply forces (once per timestep) 3.Calculate for two particles 4.If move each particle half the distance 5.If n = 2, youre done!

18
Essential Math for Games Relaxation Methods

19
Essential Math for Games Relaxation Methods

20
Essential Math for Games Cloth Simulation When n > 2, each particles 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)

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

22
Essential Math for Games Still More Cloth Simulation Sheer Springs

23
Essential Math for Games Still More Cloth Simulation Flex Springs

24
Essential Math for Games Articulated Bodies Pin Joints Hinges

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

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

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

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

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

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

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

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

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

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

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

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

37
Essential Math for Games 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

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

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

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

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

42
Essential Math for Games References Boxerman, Eddy and Ascher, Uri, Decomposing Cloth, Eurographics/ACM SIGGRAPH Symposium on Computer Animation (2004) Eberly, David, Game Physics, Morgan Kaufmann, 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 cs.cmu.edu/~jrs/jrspapers.html Witken, Andrew, David Baraff, Michael Kass, SIGGRAPH Course Notes, Physically Based Modeling, SIGGRAPH Yu, David, The Physics That Brought Cel Damage to Life: A Case Study, GDC 2002

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google