Ordinary Differential Equations - PowerPoint PPT Presentation

1 / 42
About This Presentation
Title:

Ordinary Differential Equations

Description:

for any shape, m and I completely describe response. 38. Rigid body equation of motion ... transform to body coordinates. see if particle is inside body shape ... – PowerPoint PPT presentation

Number of Views:183
Avg rating:3.0/5.0
Slides: 43
Provided by: rone152
Category:

less

Transcript and Presenter's Notes

Title: Ordinary Differential Equations


1
Ordinary Differential Equations
Slides borrowed from Ronen Barzel http//www.ense
ignement.polytechnique.fr/profs/informatique/Ronen
.Barzel/
2
What is an ODE?
  • Ordinary Differential Equation
  • Relates value of a function to its derivatives
  • Ordinary function of one variable
  • Partial Differential Equation (PDE) more
    variables

3
Standard ODE
  • Generic form for first-order ODE
  • Note
  • typically t is time
  • sometimes use Y instead of X, sometimes x instead
    of t
  • names sometimes confusing often

4
Why do we care?
  • Differential equations describe (almost)
    everything in the world
  • physics
  • chemistry
  • engineering
  • ecology
  • economy
  • weather
  • Also useful for animation!
  • ODEs are fundamental. PDEs build on ODEs

5
Solving differential equations
  • Analytic solutions to differential equations
  • Many standard forms, e.g.
  • But most cant be solved analytically
  • 3-body problem

6
Numerical solutions to ODEs
  • Given a function f(X,t) compute X(t)
  • Typically, initial value problems
  • Given values X(t0)X0
  • Find values X(t) for t gt t0
  • Also, boundary value problems, constrained
    problems,

7
Solving ODEs for animation
  • For animation, want a series of values
  • samples of the continuous function X(t)
  • i.e., frames of an animation

8
Path through a field
  • f(X,t) is a vector field defined everywhere
  • it may change based on t

9
Path through a field
  • f(X,t) is a vector field defined everywhere
  • X(t) is a path through the field

X0
10
Higher order ODEs
  • E.g., Mechanics has 2nd order ODE (FmA)
  • Express as 1st order ODE by defining v(t)

11
E.g., for a 3D particle
  • We have a 6 dimension ODE problem

12
For a collection of 3D particles
13
Still, a path through a field
  • X(t) maybe path in multi-body phase space
  • For ODE, its an array of numbers.

14
Intuitive solution take steps
  • Current state X
  • Examine f(X,t) at (or near) current state
  • Take a step to new value of X
  • Most solvers do some form of this

15
Aside Integral equation
  • Note, differential equation
  • is equivalent to integral equation

16
Eulers method
  • Simplest and most intuitive.
  • Define step size h
  • Given X0X(t0), take step
  • Piecewise-linear approximation to the curve

17
Step size controls accuracy
  • Smaller steps more closely follow curve
  • For animation, may need to take many small steps
    per frame

18
Eulers method inaccurate
  • Moves along tangent can leave curve, e.g.
  • Exact solution is circle
  • Eulers spirals outwardno matter how small h
    is

19
Eulers method unstable
  • Exact solution is decaying exponential
  • Limited step size
  • If k is big, h must be small

20
Analysis Taylor series
  • Expand exact solution X(t)
  • Eulers method approximates
  • First-order method Accuracy varies with h
  • To get 100x better accuracy need 100x more steps

21
2nd-order methods
  • Midpoint
  • ½ Euler step
  • evaluate fm
  • full step using fm
  • Trapezoid
  • Euler step
  • evaluate f1
  • full step using f1
  • average (a) and (c)

Midpoint method
22
Runge-Kutta method
  • Follow same derivation for higher order
  • 4th order
  • This is what most people use most often

23
Adaptive step size
  • How do you pick the step size?
  • Want large as possible given acceptable error.
  • Best step size might change along path
  • harder and easier parts of the path
  • decrease/increase step size as needed
  • Automatic adaptive step size control

24
Adaptive step size
  • Given h, take step and estimate error
  • if error is too large, try again with smaller h
  • if error is small, accept step and maybe increase
    h
  • Estimate error compute X(t0h) two ways
  • compute Xa by taking one step using h
  • compute Xb by taking two steps using h/2
  • estimated error err Xa Xb

25
Step size for animation
  • Want values at regular frame times
  • Can make sure not to step past next frame
  • OK if h ltlt df
  • Can step past frame, then interpolate back
  • OK if h df
  • Need interpolation anyway when doing collisions

26
Is there a solution?
  • The function f(X,t) must be smooth
  • None of these solvers handle discontinuity
  • Adaptive step size may drop to smallest h
  • Sometimes desired solution has discontinuity
  • Rigid-body collisions have discontinuous v
  • ODE solver cant step across discontinuity.

27
Which solver to choose?
  • Many more kinds of ODE solvers
  • predictor-corrector, boundary-value problems,
    semi-implicit, differential-algebraic equations,
  • Multi-step methods keep history of previous
    values
  • Adaptive-order methods
  • For hard problems, need to understand theory
  • lots of theory!
  • Runge-Kutta (4th order) is a standard workhorse
  • Try to avoid stiff equations!
  • Often need to experiment and see what works

28
For animation
  • Dont need to be accurate, just look good.
  • Eulers method w/fixed step size
  • Always a bad idea.
  • Unless it works for you!

29
Particle motion
  • mass m, position x, velocity v
  • equations of motion
  • ODE

30
Mass-spring systems
  • Basically same as a particle system
  • Structured, rather than free form
  • Mass points part of model
  • no generators, no lifetime, no aging
  • Use spring forces to connect masses
  • all forces no longer apply to all points
  • Each force object knows which points it acts on

31
Mass spring systems
  • Connect points in 1D line
  • used for hair, springs, etc
  • Connect points in 2D mesh
  • used for cloth
  • Connect points in 3D lattice
  • semi-rigid structures
  • used for flesh/muscle motion
  • e.g. Jurassic park dinosaurs

32
Spring to fixed point
  • Basic Hookes-law spring force
  • Attracts mass to point x0
  • Causes oscillation

33
Damped spring
  • Spring and dashpot
  • like a car suspension
  • only damps motion in direction of spring

34
Damped spring
  • Relationship between ks and kd determines
  • underdamping, critical damping, overdamping
  • (in isolation)
  • Always want some damping.

35
Constructions with springs
  • connect mass points to make objects
  • shapes can kink, shear, or collapse
  • add extra supports
  • can still be tricky to get desired behavior

36
Multiple springs
  • Each spring tries to achieve E0
  • Competition between multiple forces
  • Result is compromise when stable E?0
  • To guarantee result, need constraints

37
Rigid body state
  • Same as points
  • m is the total mass
  • x is the position of the center of mass
  • v is the velocity of the center of mass
  • Plus new terms
  • I is the rotational inertia tensor (scalar in
    2Dmatrix in 3D)
  • ? is the orientation (angle in 2D messy in 3D)
  • ? is the angular velocity (scalar in 2D vector
    in 3D)
  • Body coordinates
  • origin at x, orientation ? relative to World
  • for any shape, m and I completely describe
    response

38
Rigid body equation of motion
  • Equation of motion has extra terms
  • T is torque

39
Torque
  • Each force f acts at a point on body
  • r is vector from center of mass to point of
    action
  • Torque causes body to spin
  • if force acts at center of mass, no torque
    (gravity)
  • if force points towards center of mass, torque0
  • f at r and f at r give net torque but no net
    force

40
Collisions
  • Collisions between two bodies
  • Need point of collision, and normal vector
  • many algorithms
  • For body-particle collision
  • transform to body coordinates
  • see if particle is inside body shape
  • compute collision normal in body coordinates
  • compute relative velocity in body coordinates
  • compute impulse in body coordinates
  • transform back to world and apply

41
Whats a constraint?
  • A restriction on the position of a body
  • A relationship between one or more bodies
  • Permanent constraints
  • holonomic expressed by equation C()0
  • Joints between bodies
  • Transient constraints
  • nonholonomic expressed by equation C()?0
  • contact
  • joint limits

42
Constraint forces
  • First compute non-constraint forces
  • gravity, springs, etc
  • Then compute force due to constraint
  • takes into account effect of non-constraint
    forces.
  • Can have multiple constraints
  • each constraint must take into account the others
  • simultaneous equation
  • Add constraint forces to non-constraint forces
  • Simulate normally.
Write a Comment
User Comments (0)
About PowerShow.com