Final exam date Final exam date has been announced: Dynamics III - - PDF document

final exam date
SMART_READER_LITE
LIVE PREVIEW

Final exam date Final exam date has been announced: Dynamics III - - PDF document

Final exam date Final exam date has been announced: Dynamics III Tuesday, February 27, 2007 2:45 - 4:45pm Numerical Integration 70-1435 Projects Assignments Presentations: Assignment 1 -- Framework Most have been


slide-1
SLIDE 1

1

Dynamics III

Numerical Integration

Final exam date

 Final exam date has been announced:

 Tuesday, February 27, 2007  2:45 - 4:45pm  70-1435

Projects

 Presentations:

 Dates:

 Week 9: Wed, Feb 14  Week 10: Mon, Feb 19  Finals Week: Tues, Feb 27 (2:45-4:45)

 15 minutes / presentation  Schedule now on Web  Please send me choice of time/day

Assignments

 Assignment 1 -- Framework

 Most have been graded  If not submitted please do so.

 Assignment 2 -- Keyframing

 Due Friday, Jan 12.  Questions?

 Assignment 3 -- Billiards

 To be given today

Logistics

 Course Withdrawal deadline

 Friday, January 26th

Potential job opportunity

 Prof Raj will be teaching a course on

Saturdays to high school students.

 Looking for lab assistants  7 Saturdays thru May  Please contact rkr@cs.rit.edu

slide-2
SLIDE 2

2

Plan

 Physics 101 for rigid body animation

 Last Mon: translation and rotational dynamics  Last Wed: Forces, impacts, and collisions  Today: Numerical integration.

 But first…

Motivation Films

 Computer Animated Feature Films

 35 since (and including) Toy Story  17 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 #3

 A Night at the Pool Hall

slide-3
SLIDE 3

3

Laws of Motion

Law I

Every object in a state of uniform motion tends to remain in that state of motion unless an external force is applied to it. (Inertia)

Law II:

The acceleration of a body is proportional to the resulting force acting on the body, and this acceleration is in the same direction as the force.

Law III:

For every action there is an equal and opposite reaction.

Linear Motion

 For Linear Physical Motion

Mass

 Measure of the amount of matter in a body  From Law II: Measure of the a body’s resistance to motion 

Velocity

 Change of motion with respect to time 

Acceleration

 Change of velocity with respect to time 

Force

 In short, force is what makes objects accelerate 

Momentum

 mass x velocity  Another way of stating Law I: Momentum is conserved

Rotational Motion

 For Rotational Physical Motion

Inertia

 Measure of the amount/distribution of matter in a body  From Law II: Measure of the a body’s resistance to motion 

Angular Velocity

 Change of rotation with respect to time 

Angular Acceleration

 Change of velocity with respect to time 

Torque

 In short, torque is what makes objects rotate 

Angular Momentum

 Inertia x velocity  Another way of stating Law I: Momentum is conserved

Where we are

Object properties Position, orientation Linear and angular velocity Linear and angular momentum mass Calculate forces Calculate accelerations Using mass, momenta Update object properties

Where we are

 State of object at any given time

position

rotation (in world coords) momentum angular momentum

  • =

) ( ) ( ) ( ) ( ) ( t L t M t R t s t S

Where we are

 Derivative of object state

  • =
  • =

) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( ) ( t t F t R t t v t L t M t R t s t S

  • &

& & & &

slide-4
SLIDE 4

4

Putting it all together

 Step 1

 Calculate Forces, F(t), τ(t)

 Step 2

 Integrate position/rotation  s(t +Δt) = s(t) + v(t)Δt  R(t +Δt) = R(t) + (ω(t)*R(t)) Δt /* CAREFUL HERE */  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

Putting it all together

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

Putting It all together

 Step 3

 Calculate velocities (for next step)

 v(t +Δt) = M(t +Δt)/m + impulse  I-1(t +Δt) = R(t +Δt)I-1

body R(t +Δt)T

 ω(t +Δt) = + I-1(t +Δt)L(t +Δt) + impulse

 Go to step 1  Questions?

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

slide-5
SLIDE 5

5

Numerical Integration

 And  For most interesting cases, this integral

cannot be calculate analytically

  • +

=

t t

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

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

slide-6
SLIDE 6

6

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 + + = +

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

  • +

+

  • +

=

+

slide-7
SLIDE 7

7

Numerical Integration

 Midpoint method

 But how does one calculate?  Use Euler

) 2 , 2 ( x x h t f

i i

  • +

+

  • 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

+ + + + =

+

slide-8
SLIDE 8

8

Numerical Integration

 4O Rutta-Kunge

 Find k1

 k1 = h f’ (ti, xi)

Note: we have this

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

+ + + + + =

+

slide-9
SLIDE 9

9

Numerical Integration

 But does all this really matter?

 Consider projectile motion  applet

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?

slide-10
SLIDE 10

10

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?

Break

 After break

 Assignment #3