Paper Summaries Any takers? Dynamics III Numerical Integration - - PDF document

paper summaries
SMART_READER_LITE
LIVE PREVIEW

Paper Summaries Any takers? Dynamics III Numerical Integration - - PDF document

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)


slide-1
SLIDE 1

1

Dynamics III

Numerical Integration

Paper Summaries

Any takers?

Projects

Question about presentations

We have approx 19 projects

Presentations: 15 minutes (max) per project Sign up for time via e-mail (first come / first served) Week 10 and exam week.

Grad Reports

We have 10

Please indicate topic by end of day (e-mail) 20 minutes per presentation Week 9

Projects

Exam Week Presentation day:

Thursday, March 2nd 12:30pm -- 2:30pm Room 70-3445

Assignment 1

slerp

Important that your quaternions be

normalized

Assignment 1 due today

Use mycourses dropbox Be sure to indicate platform / how to build.

Jobs

Co-op at Intel

GPU Group doing 3D in hardware Looking for summer co-op Possibly 2 blocks Interested? Get resume to me ASAP.

slide-2
SLIDE 2

2

Plan for today

Continue Physics 101

we spoke about linear motion we spoke about rotational motion we spoke about collisions and impact Today we speak about numerical integration

Motivation Films

Computer Animated Feature Films

21 since (and including) Toy Story 19 currently in Production ฀http://www.boxofficemojo.com/genres/chart/?id= computeranimation.htm

Major players

Pixar PDI/Dreamworks Blue Sky / FOX Sony Imageworks Disney

Motivational Film

Short animations by Sony Imageworks

Motivational Film

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

Early Bloomer (2003)

Started as an in-house training exercise Shown at SIGGRAPH 2003.

Plan For Today

Topics

Numerical Integration

Life Beyond Euler

Assignment # 2

A Night at the Pool Hall

But before we start

slide-3
SLIDE 3

3

Calculating Impulse Force

The Straight Dope Where n a unit vector normal to the surface of

contact

The v’s are scalar velocities along the line of action.

[ ] [ ]

2 2 1 2 1 1 1 1 2 1 2 1

) ( ) ( 1 1 ) 1 ( ) ( r n r I n r n r I n × ×

  • +

× ×

  • +

+ + − − =

− −

m m e v v J

before

Calculating Impulse Force

www.euclideanspace.com

Numerical Integration

Problems we are considering are first

  • rder, initial value, ordinary differential

equations (ODE)

We have derivative (acceleration, velocity) We have initial values We need integral (velocity, position)

Numerical Integration

Said another way f’(t, x) = the derivate of our function at

time t at point x.

) , ( x t f v dt dx ′ = =

Numerical Integration

The derivative can be seen as forming a

vector field in 2 dimensions

Numerical Integration

And For most interesting cases, this integral

cannot be calculate analytically

′ + =

t t

dt x t f t x t x ) , ( ) ( ) (

slide-4
SLIDE 4

4

Numerical Integration

Instead

we start at an initial point x(t0) Step along the field (using f’) to determine

value at subsequent time steps

Numerical Integration

Euler method

Let

ti+ 1 = ti + h

then

) , (

1 i i i i

x t f h x x ′ ⋅ + =

+

Numerical Integration

Euler method

Assumes average gradient over h is the

gradient at time t

Numerical Integration

Euler Method

Pros

Easy Intuitive

Cons

Error prone Can be unstable

Numerical Integration

Taylor series expansion of a function

L + + + + = +

3 3 3 2 2 2

! 3 ! 2 ) ( ) ( ) ( dt x d h dt x d h t dt dx h t x h t x

Euler method stops here All this is error

Numerical Integration

Euler is said to be a 1st order method

L + + + + = +

3 3 3 2 2 2

! 3 ! 2 ) ( ) ( ) ( dt x d h dt x d h t dt dx h t x h t x ) ( ) ( ) ( ) (

2

h O t dt dx h t x h t x + + = +

slide-5
SLIDE 5

5

Numerical Integration

Note that we can improve on Euler

method by reducing h

Numerical Integration

To improve, consider 2nd order terms

L + + + + = +

3 3 3 2 2 2

! 3 ! 2 ) ( ) ( ) ( dt x d h dt x d h t dt dx h t x h t x

2nd order method stops here All this is error

Numerical Integration

Problem with direct 2nd order solutions

Need both f’(t) and f’’(t) at each time to calculate

f(t)

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

Midpoint Method

Assumes average gradient over h is the

gradient at the midpoint of h

Numerical Integration

Midpoint Method

Let

ti+ 1 = ti + h

then

) 2 , 2 (

1

x x h t f h x x

i i i i

∆ + + ′ ⋅ + =

+

Numerical Integration

Midpoint method

But how does one calculate? Use Euler

) 2 , 2 ( x x h t f

i i

∆ + + ′

slide-6
SLIDE 6

6

Numerical Integration

Find midpoint

xmid = xi + (h/2) f' (ti, xi)

We know xi Derivative is ∆x / ∆t

2 ) 2 , 2 ( h x x x x h t f

i mid i i

− = ∆ + +

Numerical Integration

The Midpoint method can be shown to

have 2nd order accuracy

) ( ) 2 , 2 (

3 1

h O x x h t f h x x

i i i i

+ ∆ + + ⋅ + =

+

Numerical Integration

Midpoint Method

Pros

2nd Order accuracy Self starting

Cons

Additional application of Euler required at each

step.

Numerical Integration

Runge-Kutta Method

Family of methods symmetrical w.r.t. the

interval

Midpoint method is a 2nd order Runge-

Kutta method

Fourth order Runge-Kutta

Uses gradient at 4 points to estimate gradient

  • ver h.

Has 4th order accuracy

Numerical Integration

4th order Runge-Kutta Method

k1 = h ⋅ ′ f (ti,xi) ) 2 , 2 (

1 2

k x h t f h k

i i

+ + ′ ⋅ = ) 2 , 2 (

2 3

k x h t f h k

i i

+ + ′ ⋅ = ) , (

3 4

k x h t f h k

i i

+ + ′ ⋅ =

) 2 2 ( 6 1

4 3 2 1 1

k k k k x x

i i

+ + + + =

+

Numerical Integration

4O Rutta-Kunge

Find k1

k1 = h f’ (ti, xi)

Note: we have this

slide-7
SLIDE 7

7

Numerical Integration

4O Rutta-Kunge

Find k2

Step to midpoint using derivative from last slide Compute new derivative = (xmid – xi) / (h/2) Compute k2

) 2 , 2 (

1 2

k x h t f h k

i i

+ + ′ ⋅ =

Numerical Integration

4O Rutta-Kunge

Find k3

Step to midpoint from initial point using

derivative from last slide

Compute new derivative = (xmid – xi) / (h/2) Compute k3

) 2 , 2 (

2 3

k x h t f h k

i i

+ + ′ ⋅ =

Numerical Integration

4O Rutta-Kunge

Find k4

Staring from initial point, move to end of

interval using derivative from last slide

Compute new derivative = (xfinal – xi) / (h) Compute k4

) , (

3 4

k x h t f h k

i i

+ + ′ ⋅ =

Numerical Integration

4O Rutta-Kunge

Find xi+ 1

Now average all values

) 2 2 ( 6 1

4 3 2 1 1

k k k k x x

i i

+ + + + =

+

Numerical Integration

The 4O Runge-Kutta Method can be

shown to have 4th order accuracy

Questions?

) ( 6 1 3 1 3 1 6 1

5 4 3 2 1 1

h O k k k k x x

i i

+ + + + + =

+

Numerical Integration

But does all this really matter?

Consider projectile motion applet

slide-8
SLIDE 8

8

Numerical Integration

But does all this really matter?

Consider the pendulum applet

Numerical Integration

Euler Method

Game Physics

Numerical Integration

4th order Runge-Kutta

Game Physics

Replace with Runge-Kutta

Applying Runge-Kutta

  • Step 1
  • Calculate Forces, F(t), τ(t)
  • 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) + rbodyR(t + ∆t)

  • Update Momentum (integrate accelleration)
  • M(t + ∆t) = M(t) + F(t) ∆t
  • L(t + ∆t) = L(t) + τ(t) ∆t

Applying Runge-Kutta

Step 3

Calculate velocities (for next step)

v(t + ∆t) = M(t + ∆t)/m + impulse velocity I -1(t + ∆t) = R(t + ∆t)I -1

body R(t + ∆t)T

ω(t + ∆t) = I -1(t + ∆t)L(t + ∆t) + impulse velocity

Go to step 1 Questions?

Numerical Integration

There are certainly other, more complex methods

See “Game Physics” – Chapter 9 or Numerical Recipes. With complexity comes time

Most animation texts/papers recommend 4th order

Runge-Kutta

4th order method. Best tradeoff of complexity vs. accuracy.

Questions?

slide-9
SLIDE 9

9

Break

After break

Assignment # 2