Upload
hakien
View
229
Download
1
Embed Size (px)
Citation preview
SC1SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Particle Dynamics
Andrew WitkinCarnegie Mellon University
SC2SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Overview
• One Lousy Particle
• Particle Systems
• Forces: gravity, springs …
• Implementation and Interaction
• Simple collisions
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
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
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.
SC6SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Particle Structure
xvfm
Position
Velocity
Force Accumulator
mass
Position inPhase Space
SC7SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Solver Interface
xvfm
Get/Set State
Deriv Eval
6Dim(state)
vf m
xv
SC8SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Particle Systems
xvfm
xvfm
xvfm
xvfm
xvfm
particles n time
…xvfm
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
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.
SC11SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Forces
• Constant gravity
• Position/time dependent force fields
• Velocity-Dependent drag
• n-ary springs
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
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
SC14SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Gravity
xvfm
G
apply_funpsys
p->f += p->m * F->G
F
Force Law:
fgrav = mGParticle system
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
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
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
SC18SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Solver Interface
Get/Set State
SystemDim(state) Solver
Deriv Eval
You areHere
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.
SC20SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Normal and Tangential Components
VN = (N⋅V)NVT = V - VN
VT
VN
V N
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.
SC22SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Collision Response
VN
VT
-krVN
V
V′ = VT - krVN
V′VT
Before After
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 < ε
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
SC25SIGGRAPH ’97 COURSE NOTES PHYSICALLY BASED MODELING
Basic 2-D Interaction
XOperations:
– Create
– Attach
– Drag
– Nail
Cursor
MouseSpring
Nail
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.