Advanced Algorithms
• Hierarchical Kinematic Modeling
Particle Systems
CMPT 466
Computer Animation
Torsten Möller
– Forward Kinematics
– Inverse Kinematics
• Rigid Body Constraints
– Basic Particle Forces
– Collision
• Controlling Groups of Objects
– particle systems
– flocking behaviour
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Reading
What is a Particle System?
• Chapter 4 of Parents book
• William T. Reeves, "Particle Systems A Technique for Modeling a Class of
Fuzzy Objects", pp. 359-376,
(SIGGRAPH 83).
• "Particle Animation and Rendering
Using Data Parallel Computation", Karl
Sims, pp. 405-413 (SIGGRAPH 90)
© Möller/Parent/Machiraju
• Simply a series of individual particles
–
–
–
–
Velocity
Position
Color
Lifetime
• Used to model complex systems
–
–
–
–
Fire
Smoke
Fireworks
Planets
© Möller/Parent/Machiraju
Particle Systems
Example
• Create fuzzy objects and objects whose
behavior changes with time
• tradeoff between physical simulation and
animator control:
– want motion to be physically correct
– want to have complete control available
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
It doesn’t have to be a dot…
Particle Systems
Agents @ work
© Möller/Parent/Machiraju
• The right way - perform complete physical
simulations, and determine the forces to
apply to achieve the desired motion. This is
difficult. Both of these are non-trivial.
• A practical way - Combine dynamic
simulation with kinematic control by
providing several levels of operations along
this spectrum.
© Möller/Parent/Machiraju
Particle Systems
Particle Systems
• Essence of this approach:
– positions are generated automatically
– evolution of particles is controlled
automatically
– individual particles affect final image directly
• Scale usually such that aggregate motion of
“swarm” is more apparent than internal
agent motion
• Basic loop:
– Create, kill particles
– Update positions based on:
• Previous positions, velocities, accelerations
• Exterior and interior forces
– Render particles
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle Motion
Particle Systems: Example
• Motion may be driven by:
• Combination of gravity, wind vortex,
collision forces, and pre-computed positions
(e.g., face shape “attracts” particles to it)
– Global exterior forces such as gravity, wind, predetermined path or target position, etc.
– “Contact” interactions with environment
• Collisions
• Friction
– Physical interactions with each
other
• Gravity, electrical attraction/
repulsion
• Spring connections
• Collisions
– Interior “self determination”
• AI-like perception-action feedback
© Möller/Parent/Machiraju
• Randomness
courtesy of Black Belt Systems
Initial upward and outward velocity
+ gravity = water fountain
© Möller/Parent/Machiraju
from K. Sims movie “Particle Dreams” (1988)
Particle Systems at the Movies
Particle Systems at the Movies
• First notable use (and coinage of name) was
by W. Reeves in “Star Trek II: Wrath of
Khan” (1982) for the “Genesis” effect
Particle are created, they move, and then go extinct (so the effect is localized)
“XXX” (2002)
Avalanche effect by Digital Domain
~150,000 particles
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle Systems at the Movies
Particle Systems
• Differ from other representations:
– clouds of particles define objects volume
(NO explicit boundary)
• not static - particles are
courtesy of lordoftherings.net
– born / change and move / die
• non deterministic
“The Two Towers” (2002)
Soldiers in battle scenes are articulated particles that
each run small AI program to guide motion, actions
– stochastic processes create and change
appearance and shape of particles
courtesy of massivesoftware.com
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle Systems
Particle Systems
• For each frame in a particle system’s
lifetime, we must:
–
–
–
–
–
generate new particles
assign new particle’s attribute
remove particles past their lifetime
move and transform remaining particles
render the image
• particles systems can be “trees”, i.e. each
particle is actually another P.S.
Reaction to environment
Aging: Time-varying attributes
birth
Source
death
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particles - Generation
Particles - Generation
• Number of particles affects the density of
the image
• 2 ways of controlling # of particles:
– control mean # and variance:
Nparts = Nmean + Rand()*Varparts
• grow and shrink intensity of system of
particles:
Nmean = Ninit + !Nmean * (f-f0)
(where f is the frame number)
(Rand - random variable often between 0 and 1)
– make # of particles depend on screen size of
object:
Nparts = (Nmean + Rand()*Varparts)* f(scr.Area)
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Modeling The Particle
• We know each particle is independent
• Have the following attributes
–
–
–
–
–
–
X and Y coordinates
X velocity
Y velocity
Color, Size (or image)
Lifetime
Shape
• Each particle may start with the same or different
location
• Each particle usually starts out with a different x
and y velocity © Möller/Parent/Machiraju
Particle - Attributes
• shape of a system may constrain direction
of initial velocity
Particle - Attributes
• These shapes positioned, oriented in a 3D
world
• initial position of particle is with respect to
shape of particle system
© Möller/Parent/Machiraju
Particle - Attributes
• compute speed by:
– speedinit = speedmean + Rand()*Varspeed
– for a sphere - particles move outward from
center
– for a disk - they move
upward (maybe with
an “ejection” angle)
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle Systems
• Levels of operations between explicit
kinematic control and physically based
simulations
– position operations (kinematics)
– velocity operations
– acceleration operations (dynamics)
• simulate time increment
Particle - Dynamics
• To move particle, add velocity vector
• can add acceleration factor to simulate
gravity
• particles can change color, transparency and
size over time
• control these changes by global or local
rate-of-change parameters
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Forces
Motion with Dynamics
• Unary: gravity, viscosity
• N-ary: spring, etc.
• Environmental: repulsion forces, reaction to
collisions
• simulate time increment Dt:
– A = F/m, if using forces
– V = V + A!t
– P = P + V!t
• works ok, if !t is small enough that the
acceleration and velocity are nearly constant
over !t.
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Forces
n-ary Forces: Springs
• Unary: “Global” forces applied to particles
independently
• 2 connected particles a and b exert force on one
another proportional to displacement from resting
length r of spring
• Assuming time t, let
a
b
– Gravity: Can regard as constant acceleration in
downward direction:
fgravity(t) = m g
– !x = xa- xb,
– d = displacement, and
– !v = va - vb
– Drag: Resistance to motion through medium
proportional to speed:
fdrag(t) = -kd v(t)
• n-ary: Interaction forces between particles
• Then the force on a is:
[
]
f a = " k s ( #x " r) + k d #v $ d d
– Gravitational attraction
Based on proximity
– Electrical charge
Specific to connected particles
– Springs
© Möller/Parent/Machiraju
damping constant
spring constant
(“stiffness”) © Möller/Parent/Machiraju(like “spring drag”)
!
Spring systems
Cloth Simulation I
• Networks of particles connected by springs
can be used to simulate objects with elastic
properties
• For example
– 1-D: Rope, hair
– 2-D: Cloth
– 3-D: “Jello”
courtesy of M. Kass
Angular springs for hair:
Stiffness ! More “body”
© Möller/Parent/Machiraju
courtesy of F. Pfenning
Spring networks
for cloth
© Möller/Parent/Machiraju
courtesy of R. Bridson (http://www.cs.ubc.ca/~rbridson)
Cloth Simulation II
Cloth Simulation III
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
courtesy of R. Bridson (http://www.cs.ubc.ca/~rbridson)
More cloth simulations
courtesy of R. Bridson (http://www.cs.ubc.ca/~rbridson)
Particle Physics
• Accumulate forces
• Calculate acceleration
• Assume constant acceleration over
delta time
• Average velocity
= (vold+ vold+a*dt)/2 = vold + a*dt/2
• Positionnew = positionold + v*dt+a*dt2/2
(More than just spring systems are used here)
© Möller/Parent/Machiraju
from http://www.cs.virginia.edu/~gfx/Courses/2002/Animation.spring.02/; creators unknown
© Möller/Parent/Machiraju
Euler and RK Integration
• First order (linear) approximation using a
step size of !t :
x ( t + "t ) = x ( t ) + "tf ( x,t )
Passive Update: Steps
• Particle is initialized when created with
x(t) = x0 and v(t) = v0
• So assume we have x(t) and v(t); now we want:
– x(t + dt): Integrate v(t) with ODE solver
– v(t + dt): Integrate f(t)/m with ODE solver
• Just need to sum component forces acting on
particle at time t to get net force f(t). For example,
for a “cannonball” shot through the air:
f(t) = fgravity(t) + fdrag(t) + ...
!
© Möller/Parent/Machiraju
from Numerical Recipes
Particle - Extinction
• Lifetime assigned as initial attribute
• often described in frames
• compute by
– Lifetime = Lifemean + Rand()*Varlife
• delete particle if intensity drops below a
treshold
• delete particle if it goes outside an area of
interest
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle - Rendering
• In general a difficult task (e.g. to ray trace
several million particles!)
• problems:
– particles can be transparent
– can obscure other particles and/or other objects
– can cast shadows on other particles and/or other
objects
– can interact with other objects
© Möller/Parent/Machiraju
Particle - Rendering
• simplifying approaches are used
– assume each particle is a separate point light
– particles have cumulative effect on pixel
– if particles are moving, can represent as short
line (a kind of motion blur - this also helps
reduce “strobing” - i.e. temporal aliasing)
– render separately from other types of objects
and composite various scene parts
Some Code
class Particle {
double x, y, xVel, yVel;
int lifeCounter;
Particle(int startx, int starty, int velX, int velY){
x = startx; y = starty;
xVel = velX; yVel = velY;
lifeCounter = 0;
}
}
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Some Code
The Only Particle Behavior
• A particle should know how to update its position:
void updatePosition( ) {
x = x+xVel; y = y+yVel;
yVel = yVel + GRAVITY+FORCES;
lifeCounter = lifeCounter + 1;
public class ParticleSystem {
Particle[ ] particles;
final static double GRAVITY = 0.1;
int x, y;
int particlesAlive;
ParticleSystem(int numParticles, int startx, int starty) {
particles = new Particle[numParticles];
x = startx;
y = starty;
if (lifeCounter > 100) isAlive = false;
for (int i = 0; i < numParticles; i++) {
double rand = Math.random( )*2*3.14159;
double randX = Math.cos(rand)*5;
double randY = Math.sin(rand)*5;
particles[i] = new Particle(x, y, randX, randY);
}
}
© Möller/Parent/Machiraju
}
© Möller/Parent/Machiraju
The Only Particle System
Behavior
public void updateSystem() {
particlesAlive = 0;
for (int i = 0; i<particles.length; i++) {
// Tell particles to update themselves
particles[i].updatePosition();
// Count particles left in system
if (particles[i].isAlive) {
particlesAlive++;
}
}
}
Putting it All Together
ParticleSystem p
while (true) {
for all particles in p
draw p
p.updateSystem( );
}
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
More Complex Systems
Particle - Genesis
• What we saw before works for individual
systems, like a firework
• To create a series of fireworks, bring to life
several particle systems!
• Must keep track of which systems are still
active
• Generate collections of particles on
concentric circles on planet surface
• each particle position used as
location for new particle
system of a different type
– Serious slowdown
– Serious garbage potential
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle - Genesis
• position computed by adding velocity
vector to previous position
Particle - Genesis
• velocity vector can be updated with
acceleration vector (e.g. to account for
gravity)
–
–
–
–
–
choose randomly:
placing on disk
generation rate
initial velocity
lifetime
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Particle - Genesis
Flocking (C. Reynolds,
SIGGRAPH 1987)
• color started primarily red, with some green
and blue. Altered over time to fade away,
with red lasting longer to give effect of
cooling of white-hot material
• Particles for simulating simple creatures: boids
– Birds in flock
– Fish in school
– Etc.
Other work –
Brogan,
hodgins
from C. Reynolds
• Not passive—forces are internally generated
– Can be combined with external forces
• “Intentions” of each boid depend on
characteristics of local environment
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Flocking
• Geometric objects
• Many objects
• Simple motion - e.g., local rules, more
physics, collision avoidance
• Consider other members.
Local Control
• Perception
• Physics
• Reasoning and Reaction
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Flocking: Local Environment
Boid Flocking Behaviors
• Simulating vision in “murky water”, each
boid only influenced by boids in
neighborhood:
– Distance less than some threshold
– Angle from heading within peripheral vision
range
• Basic (in priority order)
– Collision Avoidance: Steer away
from too-close flockmates
– Velocity Matching: Align direction
and speed with nearby flockmates
– Flock Centering: Attempt to stay
close to nearby flockmates
• More control:
Collision avoidance
Velocity matching
– Have leader(s) that don’t follow rules
above trace spline path to “guide” things
– Randomness and awareness of fixed
obstacles in environment
© Möller/Parent/Machiraju
courtesy of C. Reynolds
© Möller/Parent/Machiraju
Centering
courtesy of C. Reynolds
Local Perception
•
•
•
•
•
•
Limited field of view - modified by speed
Importance by distance, proximity, angle
Avoid bumping into neighbors
Stay close to neighbors
Match velocity of neighbors
Draft behind member immediately ahead
Global Perception
•
•
•
•
General migratory urge
Drawn to flock center
Follow designated leader
Not realistic, but facilitates control
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Physics
Flocking Behaviors: Physics
• Flight - thrust, lift, drag, gravity
• Perception Forces - flock centering,
migration urge, etc.
• Other Forces - wind, collision avoidance
• Each behavior generates an acceleration a(t)
directly (no consideration of mass)
• Electric charge-like model is followed:
– Attractions and repulsions allowed
– Magnitude of induced acceleration falls off with
inverse square of distance (0 outside neighborhood)
• Component accelerations are combined with
weights for “personality” control:
a(t) = wavoidaavoid(t) + wmatchamatch(t) + wcenteracenter(t)
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Negotiating the Motion
Collision Avoidance
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Collision Avoidance
Collision Avoidance
© Möller/Parent/Machiraju
© Möller/Parent/Machiraju
Steer To Avoid
- Simulating Sight
• Steer to closest point on
boundary sphere
• Steer to closest point on
boundary of silhouette
• Steer to first
non-intersecting feeler
• Steer to closest background
point of projection.
© Möller/Parent/Machiraju
Flocking - Recap
• Fewer members than in particle systems
• Knowledge of, and reaction to, other
members
• More physics - modeling flight, banking,
etc.
• More “intelligence” - reasoning about path
• Emergent Behavior - global behavior from
local rules
© Möller/Parent/Machiraju
© Copyright 2026 Paperzz