1 / 26

Integration Techniques

Integration Techniques. Marq Singer (marq@essentialmath.com). 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. The Problem. Physical simulation with force dependant on position or velocity

lilli
Download Presentation

Integration Techniques

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. Integration Techniques Marq Singer (marq@essentialmath.com)

  2. 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. The Problem • Physical simulation with force dependant on position or velocity • Start at x0, v0 • Only know: Essential Math for Games

  4. 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. 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. 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. 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. Midpoint Method • Writing it out: • Can still oscillate if h is too large Essential Math for Games

  12. 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. 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. 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. Implicit Methods • Result of backwards Euler • Solution converges more slowly • But it converges! x x0 x1 x2 t Essential Math for Games

  16. 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. Implicit Methods • Example of predictor-corrector: Essential Math for Games

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

  19. 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. Verlet Integration • Others: • Leapfrog Verlet • Velocity Verlet Essential Math for Games

  21. 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. 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. 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. 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

More Related