Paper Summaries � Any takers? Dynamics III Numerical Integration Projects Projects � Question about presentations � Exam Week Presentation day: � We have approx 19 projects � Thursday, March 2nd � Presentations: � 15 minutes (max) per project � 12:30pm -- 2:30pm � Sign up for time via e-mail (first come / first served) � Week 10 and exam week. � Room 70-3445 � Grad Reports � We have 10 � Please indicate topic by end of day (e-mail) � 20 minutes per presentation � Week 9 Assignment 1 Jobs � slerp � Co-op at Intel � Important that your quaternions be � GPU Group doing 3D in hardware normalized � Looking for summer co-op � Possibly 2 blocks � Assignment 1 due today � Use mycourses dropbox � Interested? Get resume to me ASAP. � Be sure to indicate platform / how to build. 1
Plan for today Motivation Films � Computer Animated Feature Films � Continue Physics 101 � 21 since (and including) Toy Story � we spoke about linear motion � 19 currently in Production � we spoke about rotational motion � http://www.boxofficemojo.com/genres/chart/?id= computeranimation.htm � we spoke about collisions and impact � Major players � Pixar � PDI/Dreamworks � Today we speak about numerical integration � Blue Sky / FOX � Sony Imageworks � Disney Motivational Film Motivational Film � Short animations by Sony Imageworks � The ChubbChubbs (2002) � First animated short produced by Sony Imageworks � Previewed before Men in Black II. � Winner of the 2002 Academy Award for best animated short. Motivational Film Plan For Today � Early Bloomer (2003) � Topics � Started as an in-house training exercise � Numerical Integration � Shown at SIGGRAPH 2003. � Life Beyond Euler � Assignment # 2 � A Night at the Pool Hall � But before we start 2
Calculating Impulse Force Calculating Impulse Force � The Straight Dope − − + ( v v ) ( e 1 ) = 1 2 before J [ ] [ ] 1 1 + + • − × × + • − × × 1 1 n I ( r n ) r n I ( r n ) r 1 1 1 2 2 2 m m 1 2 � Where n a unit vector normal to the surface of contact � The v’s are scalar velocities along the line of action. www.euclideanspace.com Numerical Integration Numerical Integration � Problems we are considering are first � Said another way order, initial value, ordinary differential dx ′ = = equations (ODE) v f ( x t , ) dt � We have derivative (acceleration, velocity) � We have initial values � f’(t, x) = the derivate of our function at � We need integral (velocity, position) time t at point x. Numerical Integration Numerical Integration � The derivative can be seen as forming a � And vector field in 2 dimensions t ∫ = + ′ x ( t ) x ( t ) f ( t , x ) dt 0 t 0 � For most interesting cases, this integral cannot be calculate analytically 3
Numerical Integration Numerical Integration � Instead � Euler method � we start at an initial point x(t 0 ) � Let � t i+ 1 = t i + h � Step along the field (using f’) to determine value at subsequent time steps � then = + ⋅ ′ x x h f ( t , x ) + i 1 i i i Numerical Integration Numerical Integration � Euler method � Euler Method � Assumes average gradient over h is the � Pros gradient at time t � Easy � Intuitive � Cons � Error prone � Can be unstable Numerical Integration Numerical Integration � Euler is said to be a 1 st order method � Taylor series expansion of a function 2 2 3 3 dx h d x h d x + = + + + + 2 2 3 3 L dx h d x h d x x ( t h ) x ( t ) h ( t ) + = + + + + L x ( t h ) x ( t ) h ( t ) 2 3 dt 2 ! dt 3 ! dt 2 3 dt 2 ! dt 3 ! dt dx + = + + 2 x ( t h ) x ( t ) h ( t ) O ( h ) dt Euler All this is method stops error here 4
Numerical Integration Numerical Integration � To improve, consider 2 nd order terms � Note that we can improve on Euler method by reducing h 2 2 3 3 dx h d x h d x + = + + + + L x ( t h ) x ( t ) h ( t ) 2 3 dt 2 ! dt 3 ! dt 2 nd order All this is method stops error here Numerical Integration Numerical Integration � Problem with direct 2 nd order solutions � Midpoint Method � Need both f’(t) and f’’(t) at each time to calculate � Assumes average gradient over h is the f(t) gradient at the midpoint of h � Which we don’t have � Recall, we are calculating v(t) by applying a first order to a(t) then calculating x(t) by applying first order to v(t) � There is a way to get around this (Adams-Bashforth method), but would require several values for f(t - ∆ t), f’(t - 2 ∆ t), etc to calculate f(t). � I.e. Not self-starting Numerical Integration Numerical Integration � Midpoint Method � Midpoint method � Let � But how does one calculate? ∆ h x � t i+ 1 = t i + h ′ + + f ( t , x ) i i 2 2 � then ∆ h x � Use Euler ′ = + ⋅ + + x x h f ( t , x ) + i 1 i i i 2 2 5
Numerical Integration Numerical Integration � Find midpoint � The Midpoint method can be shown to have 2 nd order accuracy � x mid = x i + (h/2) f' (t i, x i ) � We know x i ∆ h x � Derivative is ∆ x / ∆ t = + ⋅ + + + 3 x x h f ( t , x ) O ( h ) + i 1 i i i 2 2 ∆ − h x x x + + = mid i f ( t , x ) i i h 2 2 2 Numerical Integration Numerical Integration � Runge-Kutta Method � Midpoint Method � Family of methods symmetrical w.r.t. the � Pros interval � 2 nd Order accuracy � Midpoint method is a 2 nd order Runge- � Self starting Kutta method � Cons � Fourth order Runge-Kutta � Additional application of Euler required at each � Uses gradient at 4 points to estimate gradient step. over h. � Has 4 th order accuracy Numerical Integration Numerical Integration � 4 th order Runge-Kutta Method � 4O Rutta-Kunge Note: we have this k 1 = h ⋅ ′ f ( t i , x i ) � Find k 1 � k 1 = h f’ (t i, x i ) h k ′ = ⋅ + + 1 k h f ( t , x ) 2 i i 2 2 h k ′ = ⋅ + + k h f ( t , x 2 ) 3 i i 2 2 = ⋅ ′ + + k h f ( t h , x k ) 4 i i 3 1 = + + + + x x ( k 2 k 2 k k ) + i 1 i 1 2 3 4 6 6
Numerical Integration Numerical Integration h k h k = ⋅ ′ + + ′ � 4O Rutta-Kunge = ⋅ + + � 4O Rutta-Kunge ( , 2 ) k h f t x k h f ( t , x 1 ) 3 i i 2 i i 2 2 2 2 � Find k 2 � Find k 3 � Step to midpoint using derivative from last slide � Step to midpoint from initial point using derivative from last slide � Compute new derivative = (x mid – x i ) / (h/2) � Compute new derivative = (x mid – x i ) / (h/2) � Compute k 2 � Compute k 3 Numerical Integration Numerical Integration � 4O Rutta-Kunge � 4O Rutta-Kunge 1 = ⋅ ′ + + = + + + + x x ( k 2 k 2 k k ) k h f ( t h , x k ) + i 1 i 1 2 3 4 4 i i 3 6 � Find k 4 � Find x i+ 1 � Staring from initial point, move to end of � Now average all values interval using derivative from last slide � Compute new derivative = (x final – x i ) / (h) � Compute k 4 Numerical Integration Numerical Integration � The 4O Runge-Kutta Method can be � But does all this really matter? shown to have 4 th order accuracy � Consider projectile motion 1 1 1 1 = + + + + + 5 ( ) x x k k k k O h + i 1 i 1 2 3 4 6 3 3 6 � applet � Questions? 7
Numerical Integration Numerical Integration � But does all this really matter? � Euler Method � Consider the pendulum � applet Game Physics Numerical Integration Applying Runge-Kutta � 4 th order Runge-Kutta Step 1 � Calculate Forces, F(t), τ (t) � Replace with Runge-Kutta Step 2 � Integrate position/rotation � s(t + ∆ t) = s(t) + v(t) ∆ t � q(t + ∆ t) = q(t) + 0.5 ( ω (t)q(t)) ∆ t /* normalize to avoid problems * / � R(t + ∆ t) = quatToRot (q(t + ∆ t) ) � � r(t + ∆ t) = s(t + ∆ t) + r body R(t + ∆ t) Update Momentum (integrate accelleration) � M(t + ∆ t) = M(t) + F(t) ∆ t � L(t + ∆ t) = L(t) + τ (t) ∆ t � Game Physics Applying Runge-Kutta Numerical Integration � There are certainly other, more complex methods � Step 3 � See “Game Physics” – Chapter 9 or Numerical Recipes. � Calculate velocities (for next step) � With complexity comes time � v(t + ∆ t) = M(t + ∆ t)/m + impulse velocity � Most animation texts/papers recommend 4 th order � I -1 (t + ∆ t) = R(t + ∆ t)I -1 body R(t + ∆ t) T Runge-Kutta � ω (t + ∆ t) = I -1 (t + ∆ t)L(t + ∆ t) + impulse velocity � 4 th order method. � Go to step 1 � Best tradeoff of complexity vs. accuracy. � Questions? � Questions? 8
Break � After break � Assignment # 2 9
Recommend
More recommend