lecture 226.837 fall 2001 physically based animation ordinary differential equations particle...

30
Lecture 22 6.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Upload: miles-butler

Post on 03-Jan-2016

215 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 6.837 Fall 2001

Physically Based Animation

Ordinary Differential EquationsParticle DynamicsRigid-Body DynamicsCollisions

Page 2: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 2 6.837 Fall 2001

ParticleA single particle in 2-D moving in a flow field

Position

Velocity

The flow field function dictatesparticle velocity

1

2

x

x

x

1

2

,v dv dt

xv v

tx

1x

2x

,tg x

,tv g x

Page 3: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 3 6.837 Fall 2001

Vector FieldThe flow field g(x,t) is a vector field that defines a vector for any particle position x at any time t.

How would a particle move in this vector field?

1x

2x ,tg x

Page 4: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 4 6.837 Fall 2001

Differential EquationsThe equation v = g(x, t) is a first order differential equation:

The position of the particle is computed by integrating the differential equation:

For most interesting cases, this integral cannot be computed analytically.

,d

tdt

x

g x

0

0 ,t

t

t t t dt x x g x

Page 5: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 5 6.837 Fall 2001

Numeric IntegrationInstead we compute the particle’s position by numeric integration: starting at some initial point x(t0) we step along the vector field to compute the position at each subsequent time instant. This type of a problem is called an initial value problem.

0tx

1x

2x

1tx

2tx

Page 6: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 6 6.837 Fall 2001

Euler’s MethodEuler’s method is the simplest solution to an initial value problem. Euler’s method starts from the initial value and takes small time steps along the flow:

Why does this work?

,t t t t t x x g x

Let’s look at a Taylor series expansion of function x(t):

Disregarding higher-order terms and replacing the first derivative with the flow field function yields the equation for the Euler’s method.

2 2

22d t d

t t t tdt dt

x xx x

Page 7: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 7 6.837 Fall 2001

Other MethodsEuler’s method is the simplest numerical method. The error is proportional to . For most cases, the Euler’s method is inaccurate and unstable requiring very small steps.

Other methods: Midpoint (2nd order Runge-Kutta) Higher order Runge-Kutta (4th order, 6th order) Adams Adaptive Stepsize

2t

1x

2x

Page 8: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 8 6.837 Fall 2001

Particle in a Force FieldWhat is a motion of a particle in a force field?The particle moves according to Newton’s Law:

The mass m of a particle describes the particle’s inertial properties: heavier particles are easier to move than lighter particles. In general, the force field f(x, v, t) may depend on the time t and particle’s position x and velocity v.

2

2

dma

mdt

x ff

Page 9: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 9 6.837 Fall 2001

Second-Order Differential Equations

Newton’s Law yields an ordinary differential equation of second order:

A clever trick allows us to reuse the same numeric differentiation solvers for first-order differential equations. If we define a new phase space vector y, which consists of particle’s position x and velocity v, then we can construct a new first-order differential equation whose solution will also solve the second-order differential equation.

2

2

, ,d t t

mdt

x f x v

/,

/ /

d dtddt d dt m

x x vyy

v v f

Page 10: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 10 6.837 Fall 2001

Particle SystemsHow would we compute the motion of a particle system consisting of n particles?Concatenating the phase space positions of all n particles yields a large first-order ordinary differential equation. For particles in 3-D, there will be 6n equations (3 equations for position and 3 equations for velocity of each particle):

1 1

1 1

2 2

2 2

/

/

/n n

n n n

m

dm

dt

m

x v

v f

x v

v f

x v

v f

111213111213

x

x

x

v

v

v

Page 11: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 11 6.837 Fall 2001

Particle AnimationAnimateParticles(n, y0, t0, tf){

y = y0

t = t0

DrawParticles(n, y)while(t != tf) {

f = ComputeForces(y, t)dydt = AssembleDerivative(y, f){y, t } = ODESolverStep(6n, y, dy/dt)DrawParticles(n, y)

}}

Page 12: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 12 6.837 Fall 2001

Rigid-Body DynamicsWe could compute the motion of a rigid-body by computing the motion of all constituent particles. However, a rigid body does not deform and position of few of its particles is sufficient to determine the state of the body in a phase space. We’ll start with a special particle located at the body’s center of mass.

tx

tv

?

?

t

tt

x

yv

Page 13: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 13 6.837 Fall 2001

Rigid-Body Equation of MotionThe equation of motion describes the dynamics of a rigid body: the motion of a body subjected to external forces. We already know how to write a portion of this coupled first-order differential equation:

?

?

t

d dt

dt dt M t

x

yv

?

?

t

t

v

f

Page 14: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 14 6.837 Fall 2001

Net Force

tx

tv

2 tf

3 tf

1 tf

ii

t tff

Page 15: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 15 6.837 Fall 2001

Rest of the State

If we knew the orientation of the body, we could compute the position of any body point. Let’s represent the orientation with a rotation matrix R(t). A point pb in body coordinates is transformed to world coordinates with the following equation:

The last component is the rate of change of the rotation matrix, which we’ll call angular velocity ω(t).

?

?

t

tt

x

yv

bt t t p R p x

tR

Page 16: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 16 6.837 Fall 2001

Angular VelocityAngular velocity is a vector ω(t) that encodes both the axis of rotation (with its direction) and the speed of rotation (with its speed)*.

How are the orientation matrix R(t) and the angular velocity ω(t) related? The obvious relationship is not sensible:

[matrix] [vector] d

t tdt

R ω

*This may sound like a quaternion but be careful any vector ω with magnitude 2π would represent identical orientation. That’s a singularity.

Page 17: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 17 6.837 Fall 2001

Rotation MatrixThe columns of the rotation matrix describe the world-space directions of the body-space coordinate axes.

If we can determine the rate of change of an arbitrary body vector then we can apply the sample equation to compute the rate of change of each column in the rotation matrix.

x y zt t t tR r r r

z tr

x tr

y tr

Page 18: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 18 6.837 Fall 2001

Velocity of Body Vector

The tip of the vector r moves with the speed of |ω(t)||b| and the direction of the velocity vector is perpendicular to the radius b and the axis of rotation ω(t). Therefore, we can write the velocity vector as the cross product between the angular velocity ω(t) and the radius vector b. Because the vectors ω(t) and a are collinear, we can rewrite the velocity as a function of angular velocity ω(t) and the original vector r(t).

tr

tω ba b

a b

d

tdt

r

tω a b

t tω r

Page 19: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 19 6.837 Fall 2001

Angular Velocity and OrientationThe orientation rate of change and the angular velocity are related by applying the same formula on each column of the rotation matrix. We introduce a special operator to make the expression shorter to write.

x y z

x y z

d d d dt t t t

dt dt dt dt

t t t t t t

t t

R r r r

ω r ω r ω r

ω R

Page 20: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 20 6.837 Fall 2001

Rigid-Body Equation of MotionNeed to relate rate of change of angular velocity to applied forces. This term must depend on the mass distribution.

?

t tt t td d

tM tdt dt t

t

x vR R

yv f

ω

Page 21: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 21 6.837 Fall 2001

Inertia Tensor

xx xy xz

yx yy yz

zx zy zz

I I I

t I I I

I I I

I

2 2xx

V

I M y z dV xyV

I M xy dV diagonal terms off-diagonal terms

Page 22: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 22 6.837 Fall 2001

Rigid-Body Equation of Motion

t t

t t td dt

M t tdt dt

t t t

x v

R Ry

v f

I ω τ

linear momentum

angular momentum

M t

t t

v

I ω

Page 23: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 23 6.837 Fall 2001

Net Torque

tx

tv 1

b tp

3b tp

2b tp

bi i

i

t t t τ p x f

2 tf

3 tf

1 tf

Page 24: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 24 6.837 Fall 2001

Simulations with CollisionsSimulating motions with collisions requires that we detect them (collision detection) and fix them (collision response).

0ty

1ty

2ty

3ty

Page 25: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 25 6.837 Fall 2001

Collision DetectionPlane-Particle collision can be detected by computing the signed-distance function between the boundary and the particle. In this example, collision detection is deceptively simple. Fast collision detection between many curved surface is a difficult problem. Detecting collisions betweendeformable surfaces iseven harder.

nb

pb 1 0p np b b

2 0p np b b

2 0p np b b

Page 26: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 26 6.837 Fall 2001

Collision ResponseThe mechanics of collisions are complicated and many mathematical models have been developed. We’ll just look at a one simple model, which assumes that when the collision occurs the two bodes exchange collision impulse instantaneously.

nb

pbv

?v

Page 27: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 27 6.837 Fall 2001

Frictionless Collision Model

nb

pbv

1

12

0

n nb v b v

Page 28: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 28 6.837 Fall 2001

AnimationAnimate(y0, t0, tf){

y = y0

t = t0

Draw(y)while(t != tf) {

if (Collision(y)) {t = CollisionTime(y)y = ApplyImpulse(y)

} f = ComputeForces(y, t)dydt = AssembleDerivative(y, f){y, t } = ODESolverStep(y, dy/dt)Draw(y)

}}

Page 29: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 29 6.837 Fall 2001

Animation DesignSuppose we’d like to animate a hat flying through the air and landing on a coatrack.

We can compute the hat’s motion by techniques described in this lecture, but this won’t be enough. We also have to discover what initial position and velocity will result in the hat landing on the coatrack.

Page 30: Lecture 226.837 Fall 2001 Physically Based Animation Ordinary Differential Equations Particle Dynamics Rigid-Body Dynamics Collisions

Lecture 22 Slide 30 6.837 Fall 2001

Next TimeControlling Animation