When Karl Sims did his award-winning computer animation ”Particle Dreams” twenty(!) years ago, he tortured a Connection Machine CM-2 computer with as many as 65,536 processors, using one processor for the simulation of each particle.
Today we simulate tens of thousands of particles in real-time on a single cpu – even in a browser plugin – and advanced particle systems have become common practice for the simulation of snow, rain, dust, smoke, fire, and explosions in most computer games. Modern simulation environments like Processing can be used to produce such astonishingly addicting games as Falling Sand Game, sodaplay, BallDroppings, and Souptoys.
In 2006, Traer Bernstein wrote a pretty impressing particle physics library for Processing, which actually was the inspiration for this particle system toolbox in Matlab. As a matter of fact, object oriented programming in Matlab is not really the fastest lane on the particle system highway; we are back at the good old days of some ten or twenty real-time particles. But – the main purpose of this toolbox has never been to develop state-of-the-art computer games; it was rather planned as an educational, interactive learning-by-doing playground, with the aim to understand the mechanical interactions (and maybe the mathematical background) of the particle system components. Have fun!
Table of Contents
1 Genesis
1.1 Particle System Creation
1.2 Particle Creation
1.3 Spring Creation
1.4 Attraction Creation
1.5 Simulation
2 Demos
2.1 Demo 1: Free Fall
2.2 Demo 2: Bullet Time
2.3 Demo 3: Bungee Jumping
2.4 Demo 4: Gimme ya Energy!
2.5 Demo 5: Magic Chain Cable
2.6 Demo 6: Heavy Chain Mail
2.7 Demo 7: Don’t Touch me!
2.8 Demo 8: Keep it up
2.9 Demo 9: Catch me if you Can (There’s a Hole in the Bucket)
2.10 Demo 10: The Hose
2.11 Demo 11: Polyhedrons
2.11.1 Number of Particles: 3
2.11.2 Number of Particles: 4
2.11.3 Number of Particles: 5
2.11.4 Number of Particles: 6
2.11.5 Number of Particles: 8
2.11.6 Number of Particles: 12
2.11.7 Number of Particles: 20
2.12 Demo 12: Three-Body Eight
3 Mathematical Background
3.1 May the Force be with you.
3.1.1 Gravity
3.1.2 Drag
3.1.3 Inertial Force
3.1.4 Attraction Force
3.1.5 Spring Force
3.1.6 Damping Force
3.2 Differential Equations
4 Particle System Object
4.1 Class Definition particle system
4.2 Properties particle system
4.3 Constructor particle system
4.4 Method get particles positions
4.5 Method get particles velocities
4.6 Methods kill spring, kill attraction
4.7 Method kill particle
4.8 Method advance time
5 Particle System Object (Private Methods)
5.1 Private Method kill old particles
5.2 Private Method get phase space state
5.3 Private Method compute state derivative
5.4 Private Method set phase space state
5.5 Private Method aggregate forces
5.6 Private Method clear particle forces
5.7 Private Method aggregate springs forces
5.8 Private Method aggregate attractions forces
5.9 Private Method aggregate drag forces
5.10 Private Method aggregate gravity forces
5.11 Private Method get particles accelerations
5.12 Private Method advance particles ages
5.13 Private Method update graphics positions
6 Particle Object
6.1 Class Definition and Properties particle
6.2 Constructor particle
6.3 Private Method append
6.4 Methods add force, clear force
6.5 Method delete
6.6 Method set.fixed
6.7 Method set.position
6.8 Method update graphics position
7 Spring Object
7.1 Class Definition and Properties spring
7.2 Constructor spring
7.3 Private Method append
7.4 Method delete
7.5 Method update graphics position
8 Attraction Object
A Vector Projection
B Particle System Dependency
C Particle, Attraction, and Spring Dependency
Objectives and Topics
This work provides an educational, interactive toolbox for simulating particle systems in MATLAB, focusing on the mechanical interactions and mathematical principles governing multi-particle environments.
- Implementation of particle systems with gravity, drag, and attraction forces.
- Object-oriented structure for managing particles, springs, and attractions.
- Interactive demonstrations including bungee jumping, chain simulations, and self-configuring polyhedrons.
- Mathematical background on physical motion vectors and differential equation systems.
- Integration of numerical solvers for real-time simulation.
Excerpt from the Book
2.3 Demo 3: Bungee Jumping
Wikipedia defines bungee jumping as an activity in which a person jumps off from a high place (generally of several hundred feet/meters) with one end of an elastic cord attached to his/her body or ankles and the other end tied to the jumping-off point.
Well, what do you need for a half-decent bungee jumping simulation? The jumping person is just a free particle with a certain mass and the elastic cord can be modeled by a spring between the jumper and another (hopefully fixed) ”particle”. Add some aerodynamic resistance and a bit of spring damping and the jump will look quite realistic. In order to open up the second dimension, the jumping-off point should not equal the fixed chord end point.
< Genesis mode on >
Summary of Chapters
1 Genesis: Provides an overview of how particles, springs, and attractions are created and implemented within the system.
2 Demos: Offers a collection of practical simulation examples ranging from simple free fall to complex multi-body interactions.
3 Mathematical Background: Explains the physical force vectors and the underlying differential equation system used in the toolbox.
4 Particle System Object: Details the public methods and property definitions for managing the primary particle system object.
5 Particle System Object (Private Methods): Covers internal methods for system management, force aggregation, and integration.
6 Particle Object: Describes the class definition, constructor, and methods for managing individual particle behavior and state.
7 Spring Object: Outlines the implementation of spring mechanics, including rest lengths, damping, and graphical representation.
8 Attraction Object: Discusses the logic behind attraction and repulsion forces between particles.
Keywords
MATLAB, Particle System, Physics Simulation, Computer Animation, Object-Oriented Programming, Bungee Jumping, Differential Equations, Runge-Kutta, Gravity, Drag, Spring Force, Damping, Polyhedrons, Three-Body Problem, Numerical Integration
Frequently Asked Questions
What is the primary purpose of this toolbox?
This toolbox is designed as an educational, interactive learning-by-doing playground to help users understand mechanical interactions and the underlying mathematics of particle systems.
Which programming environment is required?
The entire toolbox is implemented in MATLAB, utilizing object-oriented programming techniques.
What is the core focus of the simulation demos?
The demos focus on illustrating physical concepts like gravity, drag, and spring-damper mechanics through scenarios such as free fall, bungee jumping, and structure formation.
What mathematical method is used for the simulation?
The toolbox solves the system of nonlinear differential equations using a fixed-step fourth-order Runge-Kutta solver.
What objects are managed by the Particle System?
The system manages particles, springs, and attraction forces, each defined as distinct object types.
What do the keywords cover?
The keywords span simulation software, numerical physics, specific physical effects, and technical implementation details like object-oriented design and integration algorithms.
How does the "Bungee Jumping" demo handle physics?
It models the person as a free particle and the bungee cord as a spring with damping, requiring a fixed anchor point and gravity.
Why do the polyhedrons not always form regular shapes?
Due to the balance of spring forces and repulsions in random initial configurations, the particles sometimes reach stable equilibrium states that result in irregular polyhedrons rather than perfect Platonic solids.
- Quote paper
- Prof. Dr.-Ing. Jörg Buchholz (Author), 2008, Matlab Particles 2.0, Munich, GRIN Verlag, https://www.grin.com/document/82817