Particle Systems
Readig Required: Witki, Particle System Dyamics, SIGGRAPH 97 course otes o Physically Based Modelig. Optioal Witki ad Baraff, Differetial Equatio Basics, SIGGRAPH 97 course otes o Physically Based Modelig. Hockew ad Eastwood. Computer simulatio usig particles. Adam Hilger, New York, 1988. Gavi Miller. The motio dyamics of sakes ad worms. Computer Graphics 22:169-178, 1988. 2
What are particle systems? A particle system is a collectio of poit masses that obeys some physical laws (e.g, gravity or sprig behaviors). Particle systems ca be used to simulate all sorts of physical pheomea: Smoke Sow Fireworks Hair Cloth Sakes Fish 3
Overview 1. Oe lousy particle 2. Particle systems 3. Forces: gravity, sprigs 4. Implemetatio 4
Particle i a flow field We begi with a sigle particle with: Positio, x x = y Velocity, dx dx / dt v x& = = dt dy / dt Suppose the velocity is dictated by some drivig fuctio g: x& = g( x, t) y g(x,t) x x 5
Vector fields At ay momet i time, the fuctio g defies a vector field over x: How does our particle move through the vector field? 6
Diff eqs ad itegral curves The equatio x& = g( x, t) is actually a first order differetial equatio. We ca solve for x through time by startig at a iitial poit ad steppig alog the vector field: Start Here This is called a itial value problem ad the solutio is called a itegral curve. 7
Euler s method Oe simple approach is to choose a time step, Δt, ad take liear steps alog the flow: x( t+δ t) = x() t +Δt x& () t = x() t +Δt g( x,) t This approach is called Euler s method ad looks like: Properties: Simplest umerical method Bigger steps, bigger errors Need to take pretty small steps, so ot very efficiet. Better (more complicated) methods exist, e.g., Ruge-Kutta. 8
Particle i a force field Now cosider a particle i a force field f. I this case, the particle has: Mass, m Acceleratio, dv a x& = = dt 2 d x 2 dt The particle obeys Newto s law: f = ma= mx& The force field f ca i geeral deped o the positio ad velocity of the particle as well as time. Thus, with some rearragemet, we ed up with: (,, t) x = fxx & & m 9
This equatio: Secod order equatios (,, t) x&= fxv m is a secod order differetial equatio. Our solutio method, though, worked o first order differetial equatios. We ca rewrite this as: x& = v& = v fxv (,, t) m where we have added a ew variable v to get a pair of coupled first order equatios. 10
Phase space x v x& v& x& v = / m v& f Cocateate x ad v to make a 6-vector: positio i phase space. Takig the time derivative: aother 6-vector. A vailla 1 st -order differetial equatio. 11
Particle structure x v f m positio velocity force accumulator mass Positio i phase space 12
Solver iterface x v f m getdim getstate setstate deriveval [ 6] f x v v / m 13
Particle systems particles time x x x x 1 2 3 v 1 v 2 v 3 v L f1 f2 f3 f m1 m2 m3 m 14
Solver iterface particles time get/setstate getdim deriveval 6 x v x v L x v 1 1 2 2 f f f v v L x m m m 1 2 1 2 1 2 15
Forces Costat (gravity) Positio/time depedet (force fields) Velocity-depedet (drag) N-ary (sprigs) 16
Gravity Force law: f grav = mg p->f += p->m * F->G 17
Viscous drag Force law: f drag = kdrag v p->f -= F->k * p->v 18
Damped sprig Force law: f1 = ks( Vx r) + f = f 2 1 k d VvVx Vx Vx Vx r = rest legth x 1 Vx= x1 x2 x 2 Vv = v1 v2 19
Particle systems with forces particles time forces f F F F F x1 x2 v 1 v 2L f f x v f 1 2 m1 m2 m 20
deriveval loop 1. Clear forces Loop over particles, zero force accumulators 2. Calculate forces Sum all forces ito accumulators 3. Gather Loop over particles, copyig v ad f/m ito destiatio array 21
deriveval Loop x1 x2 v 1 v 2L f f x v f 1 2 m1 m2 m 1 Clear force accumulators 2 F F F Apply forces to particles F x1 x2 v 1 v 2L f f x v f 1 2 m1 m2 m 3 Retur [v,f/m, ] to solver 22
Solver iterface particles time get/setstate getdim deriveval 6 x v x v L x v 1 1 2 2 f f f v v L x m m m 1 2 1 2 1 2 23
Differetial equatio solver x& v = / m v& f Euler method: i+ 1 i i x 1 x 1 v 1 i+ 1 i i v1 v1 f1 / m1 M = M+ Vt M i+ 1 i i x x v i+ 1 i i v v f / m 24
Boucig off the walls Add-o for a particle simulator For ow, just simple poit-plae collisios 25
Normal ad tagetial compoets V N P N V V V N T VT = ( N V) N V = V V N 26
Collisio Detectio V X ( X P) N<ε NV < 0 Withi ε of the wall Headig i P N 27
Collisio Respose V N k r V N V VT V T Vʹ before after Vʹ = VT krvn 28
Artificial Fish 29
Crowds 30
Summary What you should take away from this lecture: The meaigs of all the boldfaced terms Euler method for solvig differetial equatios Combiig particles ito a particle system Physics of a particle system Various forces actig o a particle Simple collisio detectio 31