26
SC1 SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING Particle Dynamics Andrew Witkin Carnegie Mellon University

Particle Dynamics

  • Upload
    hakien

  • View
    229

  • Download
    1

Embed Size (px)

Citation preview

Page 1: Particle Dynamics

SC1SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Particle Dynamics

Andrew WitkinCarnegie Mellon University

Page 2: Particle Dynamics

SC2SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Overview

• One Lousy Particle

• Particle Systems

• Forces: gravity, springs …

• Implementation and Interaction

• Simple collisions

Page 3: Particle Dynamics

SC3SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

A Newtonian Particle

• Differential equation: f = ma

• Forces can depend on:

– Position, Velocity, Time

x = f(x,x,t)m

Page 4: Particle Dynamics

SC4SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Second Order Equations

x = f(x,x,t)m

Not in our standard formbecause it has 2ndderivatives

Add a new variable, v, to geta pair of coupled 1st orderequations.

{x = vv = f m

Page 5: Particle Dynamics

SC5SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Phase Space

xv

xv

xv

= vf m

Concatenate x and v to makea 6-vector: Position in PhaseSpace.

Velocity in Phase Space:another 6-vector.

A vanilla 1st-order differentialequation.

Page 6: Particle Dynamics

SC6SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Particle Structure

xvfm

Position

Velocity

Force Accumulator

mass

Position inPhase Space

Page 7: Particle Dynamics

SC7SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Solver Interface

xvfm

Get/Set State

Deriv Eval

6Dim(state)

vf m

xv

Page 8: Particle Dynamics

SC8SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Particle Systems

xvfm

xvfm

xvfm

xvfm

xvfm

particles n time

…xvfm

Page 9: Particle Dynamics

SC9SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Solver Interface

6nx1 v1 x2 v2 xn vn

v1f1m1

v2f2m2

vnfnmn

particles n time

Deriv Eval

Get/Set State

Dim(State)

Particle System

Diffeq Solver

Page 10: Particle Dynamics

SC10SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Deriv Eval Loop

• Clear forces

– Loop over particles, zero force accumulators.

• Calculate forces

– Sum all forces into accumulators.

• Gather

– Loop over particles, copying v and f/m into destination array.

Page 11: Particle Dynamics

SC11SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Forces

• Constant gravity

• Position/time dependent force fields

• Velocity-Dependent drag

• n-ary springs

Page 12: Particle Dynamics

SC12SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Force Structures• Unlike particles, forces are

heterogeneous.• Force Objects:

– black boxes– point to the particles they influence

– add in their own forces (type dependent)• Global force calculation:

– loop, invoking force objects

Page 13: Particle Dynamics

SC13SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Particle Systems, with forces

xvfm

xvfm

…xvfm

particles n time forces nforces

… FF F F

A list of forceobjects to invoke

Page 14: Particle Dynamics

SC14SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Gravity

xvfm

G

apply_funpsys

p->f += p->m * F->G

F

Force Law:

fgrav = mGParticle system

Page 15: Particle Dynamics

SC15SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Viscous Drag

fdrag = -kdragv

xvfm

k

apply_funpsys

p->f -= F->k * p->v

F

Force Law: Particle system

Page 16: Particle Dynamics

SC16SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

DampedSpring

xvfm

Fxvfm

ksp2

p1 kd

apply_fun

sys

Particle system

Force Law:

f 1 = - ks( )∆x - r + kd

∆v⋅∆x∆x

∆x∆x

f 2 = -f 1

Page 17: Particle Dynamics

SC17SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Deriv Eval Loop

… FF F FClear Force Accumulators Invoke apply_force

functions

xvfm

xvfm

…xvfm

xvfm

xvfm

…xvfm

Return [v, f/m,…]to solver.

1

2

3

Page 18: Particle Dynamics

SC18SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Solver Interface

Get/Set State

SystemDim(state) Solver

Deriv Eval

You areHere

Page 19: Particle Dynamics

SC19SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Bouncing off the Walls

• Later: rigid body collision and contact.

• For now, just simple point-plane collisions.

• Add-ons for a particle simulator.

Page 20: Particle Dynamics

SC20SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Normal and Tangential Components

VN = (N⋅V)NVT = V - VN

VT

VN

V N

Page 21: Particle Dynamics

SC21SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Collision Detection

N

X

V

P

N⋅V < 0

( )X - P ⋅N < ε

• Within ε of the wall.• Heading in.

Page 22: Particle Dynamics

SC22SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Collision Response

VN

VT

-krVN

V

V′ = VT - krVN

V′VT

Before After

Page 23: Particle Dynamics

SC23SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Conditions for Contact

NP

V

FX

• On the wall• Moving along the wall• Pushing against the wall

N⋅V < ε

( )X - P ⋅N < ε

Page 24: Particle Dynamics

SC24SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Contact Force

The wall pushes back, cancelling the normal component of F.

(An example of a constraint force.)

F

F′

N

F′ = FT

FN

Page 25: Particle Dynamics

SC25SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Basic 2-D Interaction

XOperations:

– Create

– Attach

– Drag

– Nail

Cursor

MouseSpring

Nail

Page 26: Particle Dynamics

SC26SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING

Try this at home!

The notes give you everything you need to build a basic interactive mass/spring simulator—try it.