Presentation is loading. Please wait.

Presentation is loading. Please wait.

Integration Techniques

Similar presentations


Presentation on theme: "Integration Techniques"— Presentation transcript:

1 Integration Techniques
Marq Singer

2 Essential Math for Games
Integrators Solve “initial value problem” for ODEs Used Euler’s method in previous talk But not the only way to do it Are other, more stable ways Essential Math for Games

3 Essential Math for Games
The Problem Physical simulation with force dependant on position or velocity Start at x0, v0 Only know: Essential Math for Games

4 Essential Math for Games
The Solution Do an iterative solution Start at some initial value Ideally follow a step-by-step (or stepwise) approximation of the function Essential Math for Games

5 Euler’s Method (review)
Idea: we have the slope (x or v) Follow slope to find next values of x or v Start with x0, v0, time step h Essential Math for Games

6 Essential Math for Games
Euler's Method Step across vector field of functions Not exact, but close x x0 x1 x2 t Essential Math for Games

7 Euler’s Method (cont’d)
Has problems Expects the slope at the current point is a good estimate of the slope on the interval Approximation can drift off the actual function – adds energy to system! Gets worse the farther we get from known initial value Especially bad when time step gets larger Essential Math for Games

8 Euler’s Method (cont’d)
Example of drift x x0 x2 t x1 Essential Math for Games

9 Essential Math for Games
Stiffness Running into classic problem of stiff equations Have terms with rapidly decaying values Larger decay = stiffer equation = need smaller h Often seen in equations with stiff springs (hence the name) Essential Math for Games

10 Essential Math for Games
Midpoint Method Take two approximations Approximate at half the time step Use slope there for final approximation x x0 h x1 h/2 x0.5 t Essential Math for Games

11 Essential Math for Games
Midpoint Method Writing it out: Can still oscillate if h is too large Essential Math for Games

12 Essential Math for Games
Runga-Kutta Use weighted average of slopes across interval How error-resistant indicates order Midpoint method is order two Usually use Runga-Kutta Order Four, or RK4 Essential Math for Games

13 Essential Math for Games
Runga-Kutta (cont’d) Better fit, good for larger time steps Expensive -- requires many evaluations If function is known and fixed (like in physical simulation) can reduce it to one big formula But for large timesteps, still have trouble with stiff equations Essential Math for Games

14 Essential Math for Games
Implicit Methods Explicit Euler methods add energy Implicit Euler removes it Use new velocity, not current E.g. Backwards Euler: Better for stiff equations Essential Math for Games

15 Essential Math for Games
Implicit Methods Result of backwards Euler Solution converges more slowly But it converges! x x0 x1 x2 t Essential Math for Games

16 Essential Math for Games
Implicit Methods How to compute x'i+1 or v'i+1? Derive from formula (most accurate) Compute using explicit method and plug in value (predictor-corrector) Solve using linear system (slowest, most general) Essential Math for Games

17 Essential Math for Games
Implicit Methods Example of predictor-corrector: Essential Math for Games

18 Essential Math for Games
Implicit Methods Solving using linear system: Resulting matrix is sparse, easy to invert Essential Math for Games

19 Essential Math for Games
Verlet Integration Velocity-less scheme From molecular dynamics Uses position from previous time step Stable, but not as accurate Good for particle systems, not rigid body Essential Math for Games

20 Essential Math for Games
Verlet Integration Others: Leapfrog Verlet Velocity Verlet Essential Math for Games

21 Essential Math for Games
Multistep Methods Previous methods used only values from the current time step Idea: approximation drifts more the further we get from initial value Use values from previous time steps to calculate next one Anchors approximation with more accurate data Essential Math for Games

22 Multistep Methods (cont’d)
Two types of multistep methods Explicit method determined only from known values Implicit method formula includes value from next time step Use Runga-Kutta to calculate initial values, predictor-correct for implicit Essential Math for Games

23 Multistep Methods (Cont’d)
Adams-Bashforth 2-Step Method (explicit) Adams-Moulton 2-Step Method (implicit) Essential Math for Games

24 Essential Math for Games
Variable Step Size Idea: use one level of calculation to compute value, one at a higher level to check for error If error high, decrease step size Not really practical because step size can be dependant on frame rate Also expensive, not good for real-time Essential Math for Games

25 Essential Math for Games
Which To Use? In practice, Midpoint or Euler’s method may be enough if time step is small At 60 fps, that’s probably the case Having trouble w/sim exploding? Try implicit Euler or Verlet Essential Math for Games

26 Essential Math for Games
References Burden, Richard L. and J. Douglas Faires, Numerical Analysis, PWS Publishing Company, Boston, MA, 1993. Witken, Andrew, David Baraff, Michael Kass, SIGGRAPH Course Notes, Physically Based Modelling, SIGGRAPH 2002. Eberly, David, Game Physics, Morgan Kaufmann, 2003. Essential Math for Games


Download ppt "Integration Techniques"

Similar presentations


Ads by Google