Вы находитесь на странице: 1из 26

Particle Dynamics

Andrew Witkin
Carnegie Mellon University

SIGGRAPH ’97 COURSE NOTES SC1 PHYSICALLY BASED MODELING


Overview

• One Lousy Particle


• Particle Systems
• Forces: gravity, springs …
• Implementation and Interaction
• Simple collisions

SIGGRAPH ’97 COURSE NOTES SC2 PHYSICALLY BASED MODELING


A Newtonian Particle
• Differential equation: f = ma
• Forces can depend on:
– Position, Velocity, Time

f(x,x,t)
x= m

SIGGRAPH ’97 COURSE NOTES SC3 PHYSICALLY BASED MODELING


Second Order Equations

f(x,x,t) Not in our standard form


x= m because it has 2nd
derivatives

{
Add a new variable, v, to get
x =v a pair of coupled 1st order
v =fm equations.

SIGGRAPH ’97 COURSE NOTES SC4 PHYSICALLY BASED MODELING


Phase Space
x Concatenate x and v to make
v a 6-vector: Position in Phase
Space.
x Velocity in Phase Space:
v another 6-vector.

x = v A vanilla 1st-order differential


v fm equation.

SIGGRAPH ’97 COURSE NOTES SC5 PHYSICALLY BASED MODELING


Particle Structure

x Position Position in
Phase Space
v Velocity

f Force Accumulator

m mass

SIGGRAPH ’97 COURSE NOTES SC6 PHYSICALLY BASED MODELING


Solver Interface

x Dim(state)
6

v x
f Get/Set State v
m v
Deriv Eval fm

SIGGRAPH ’97 COURSE NOTES SC7 PHYSICALLY BASED MODELING


Particle Systems

particles n time

x x x x x x
v v v v v v
f f f f f … f
m m m m m m

SIGGRAPH ’97 COURSE NOTES SC8 PHYSICALLY BASED MODELING


Particle System Solver Interface
particles n time

Dim(State)
Get/Set State Diffeq Solver
6n
Deriv Eval x1 v1 x2 v2 xn vn
f1 v f2
v1 m fn
vn m
2 m
1 2 n

SIGGRAPH ’97 COURSE NOTES SC9 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.

SIGGRAPH ’97 COURSE NOTES SC10 PHYSICALLY BASED MODELING


Forces

• Constant gravity
• Position/time dependent force fields
• Velocity-Dependent drag
• n-ary springs

SIGGRAPH ’97 COURSE NOTES SC11 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

SIGGRAPH ’97 COURSE NOTES SC12 PHYSICALLY BASED MODELING


Particle Systems, with forces

particles n time forces nforces

x x x F F F …F
v v v
f f … f A list of force
m m m
objects to invoke

SIGGRAPH ’97 COURSE NOTES SC13 PHYSICALLY BASED MODELING


Gravity
Force Law: Particle system
f grav = mG
G F
sys
x p apply_fun
v
f
m p->f += p->m * F->G

SIGGRAPH ’97 COURSE NOTES SC14 PHYSICALLY BASED MODELING


Viscous Drag
Force Law: Particle system
f drag = -kdragv
k F
sys
x p apply_fun
v
f
m p->f -= F->k * p->v

SIGGRAPH ’97 COURSE NOTES SC15 PHYSICALLY BASED MODELING


Damped
Force Law: Spring
 ∆v⋅∆x  ∆x
f 1 = - ks( ∆x - r ) + kd
 ∆x  ∆x Particle system
f 2 = -f 1

x
p1 kd sys F
v x
f v ks apply_fun
m
p2
f
m

SIGGRAPH ’97 COURSE NOTES SC16 PHYSICALLY BASED MODELING


x x x Deriv Eval Loop
v v v
1
f f … f
m m m
2
F F F …F
Clear Force
Accumulators Invoke apply_force
functions

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

SIGGRAPH ’97 COURSE NOTES SC17 PHYSICALLY BASED MODELING


Solver Interface

Dim(state) Solver
System

Get/Set State
You are
Here
Deriv Eval

SIGGRAPH ’97 COURSE NOTES SC18 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.

SIGGRAPH ’97 COURSE NOTES SC19 PHYSICALLY BASED MODELING


Normal and Tangential Components

VN

V VT
N

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

SIGGRAPH ’97 COURSE NOTES SC20 PHYSICALLY BASED MODELING


Collision Detection

X ( X - P) ⋅N < ε
V N⋅V < 0

P N • Within ε of the wall.


• Heading in.

SIGGRAPH ’97 COURSE NOTES SC21 PHYSICALLY BASED MODELING


Collision Response

VN -krV N

VT VT V′
V
Before After
V′ = V T - k rV N

SIGGRAPH ’97 COURSE NOTES SC22 PHYSICALLY BASED MODELING


Conditions for Contact
( X - P) ⋅N < ε
F
X
N⋅V < ε
V

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

SIGGRAPH ’97 COURSE NOTES SC23 PHYSICALLY BASED MODELING


Contact Force
FN
F′ = FT
F The wall pushes back,
F′ cancelling the normal
component of F.

N (An example of a
constraint force.)

SIGGRAPH ’97 COURSE NOTES SC24 PHYSICALLY BASED MODELING


Basic 2-D Interaction
Cursor
Operations:
X Mouse
Spring
Nail
– Create
– Attach
– Drag
– Nail

SIGGRAPH ’97 COURSE NOTES SC25 PHYSICALLY BASED MODELING


Try this at home!

The notes give you everything you need


to build a basic interactive mass/spring
simulator—try it.

SIGGRAPH ’97 COURSE NOTES SC26 PHYSICALLY BASED MODELING

Вам также может понравиться