numerical integration jim van verth insomniac games [email protected]
TRANSCRIPT
![Page 1: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/1.jpg)
![Page 3: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/3.jpg)
Talk Summary
Going to talk about: Euler’s method subject to errors Implicit methods help, but complicated Verlet methods help, but velocity out of step Symplectic methods can be good for both
![Page 4: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/4.jpg)
Our Test Case
![Page 5: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/5.jpg)
Our Test Case
![Page 6: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/6.jpg)
Our Test Case
xt =?
x0
![Page 7: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/7.jpg)
Constant velocity
v
xt =?
x0
![Page 8: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/8.jpg)
Constant velocity
v
xt = x0+vt
x0
![Page 9: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/9.jpg)
Constant accelerationv0
x0
xt = ?
a
![Page 10: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/10.jpg)
Constant accelerationv0
x0
xt = ?
a
![Page 11: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/11.jpg)
Constant accelerationv0
x0
xt = x0 + v0t + 1/2at2
a
![Page 12: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/12.jpg)
Variable acceleration
x0
xt = ?
![Page 13: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/13.jpg)
Euler’s method
x0
v0
![Page 14: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/14.jpg)
Euler’s method
x0
v0
x1
![Page 15: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/15.jpg)
Euler’s method
x0
v0
x1
v0a
![Page 16: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/16.jpg)
Euler’s method
x0
v0
x1
v0a
v1
![Page 17: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/17.jpg)
Euler’s method
x0
v0
x1v1
![Page 18: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/18.jpg)
Euler’s method
x0
v0
x1v1
x2
![Page 19: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/19.jpg)
Euler’s method
x0
v0
x1v1
a
v1
x2
![Page 20: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/20.jpg)
Euler’s method
x0
v0
x1v1
a
v1
v2
x2
![Page 21: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/21.jpg)
Euler’s method
x0
v0
x1v1
v2
x2
![Page 22: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/22.jpg)
Euler’s method
x0
v0
x1v1
v2
x2
€
x i+1 = x i + viΔt
vi+1 = vi +a iΔt
![Page 23: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/23.jpg)
Euler’s method
x0v0
a0
![Page 24: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/24.jpg)
Euler’s method
x1
x0v0
a0
![Page 25: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/25.jpg)
Euler’s method
x0x1a0
v0v0
![Page 26: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/26.jpg)
Euler’s method
v1 x0x1
v0v0
a0
![Page 27: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/27.jpg)
Euler’s method
x0x1
v0
v1
![Page 28: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/28.jpg)
Euler’s method
x2
v2
x0x1
v0
v1
![Page 29: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/29.jpg)
Euler’s method
x0
x1v1
v0
![Page 30: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/30.jpg)
Euler
Okay for non-oscillating systems Explodes with oscillating systems Adds energy! Very bad!
![Page 31: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/31.jpg)
Runge-Kutta methods
x0
v0
![Page 32: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/32.jpg)
Runge-Kutta methods
x0
v0
v0.5
![Page 33: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/33.jpg)
Runge-Kutta methods
x0
v0.5
![Page 34: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/34.jpg)
Runge-Kutta methods
x0
v0.5
x1
![Page 35: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/35.jpg)
Runge-Kutta methods
x0
v0
![Page 36: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/36.jpg)
Runge-Kutta 4
Very stable and accurate Conserves energy well But expensive: four evaluations of derivative
![Page 37: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/37.jpg)
Implicit methods
x0v0
![Page 38: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/38.jpg)
Implicit methods
x0v0
x1
![Page 39: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/39.jpg)
Implicit methods
x0v0
x1v1
![Page 40: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/40.jpg)
Implicit methods
x0v0
v1
![Page 41: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/41.jpg)
Implicit methods
x0v0
x1
v1
![Page 42: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/42.jpg)
Implicit methods
x0v0
€
x i+1 = x i + vi+1Δt
vi+1 = vi +a i+1Δt
x1
v1
![Page 43: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/43.jpg)
Implicit methods
x0v0
€
x i+1 = x i + vi+1Δt
vi+1 = vi +a i+1Δt
x1v1
![Page 44: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/44.jpg)
Implicit methods
x0v0
€
x i+1 = x i + vi+1Δt
vi+1 = vi +a i+1Δt
x1
v1
![Page 45: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/45.jpg)
Backward Euler
Not easy to get implicit values More expensive than Euler
But tends to converge: better but not ideal
![Page 46: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/46.jpg)
Verlet
x0 x-1
![Page 47: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/47.jpg)
Verlet
x0 x-1
![Page 48: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/48.jpg)
Verlet
x0at2 x-1
![Page 49: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/49.jpg)
Verlet
x0
x1
x-1at2
![Page 50: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/50.jpg)
Verlet
€
x i+1 = 2x i − x i−1 +aΔt 2
x0
x1
x-1at2
![Page 51: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/51.jpg)
Verlet
Leapfrog Verlet
Velocity Verlet
€
vi+1/ 2 = vi−1/ 2 +a iΔt
x i+1 = x i + vi+1/ 2Δt
€
vi+1/ 2 = vi +a iΔt /2
x i+1 = x i + vi+1/ 2Δt
vi+1 = vi+1/ 2 +a i+1Δt /2
![Page 52: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/52.jpg)
Verlet
Very stable Cheap
Not too bad, but have estimated velocity
![Page 53: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/53.jpg)
Symplectic Euler
x0v0
a0
![Page 54: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/54.jpg)
Symplectic Euler
x0v0
v1
v0
a0
![Page 55: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/55.jpg)
Symplectic Euler
x0
v1
![Page 56: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/56.jpg)
Symplectic Euler
€
vi+1 = vi +a iΔt
x i+1 = x i + vi+1Δt
x0
v1
![Page 57: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/57.jpg)
Symplectic Euler
€
vi+1 = vi +a iΔt
x i+1 = x i + vi+1Δt
![Page 58: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/58.jpg)
Symplectic Euler
Cheap and stable!
Not as accurate as RK4
![Page 59: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/59.jpg)
Symplectic Euler
Cheap and stable!
Not as accurate as RK4 - but hey, it’s a game
![Page 60: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/60.jpg)
Demo Time
![Page 61: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/61.jpg)
Which To Use? With simple forces, standard Euler might be okay But constraints, springs, etc. require stability Recommendation: Symplectic Euler
Generally stable Simple to compute (just swap velocity and position terms)
More complex integrators available if you need them -- see references
![Page 62: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/62.jpg)
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.
![Page 63: Numerical Integration Jim Van Verth Insomniac Games jim@essentialmath.com](https://reader038.vdocuments.us/reader038/viewer/2022102618/5513d05755034674748b4c90/html5/thumbnails/63.jpg)
References
Hairer, et al, “Geometric Numerical Integration Illustrated by the Störmer/Verlet method,” Acta Numerica (2003), pp 1-51.
Robert Bridson, Notes from CPSC 533d: Animation Physics, University of BC.