Matlab Particles 2.0
Jörg J. Buchholz
July 29, 2007
Introduction ... 5
1 Genesis ... 7
1.1 Particle System Creation ... 7
1.2 Particle Creation ... 8
1.3 Spring Creation ... 9
1.4 Attraction Creation ... 10
1.5 Simulation ... 10
2 Demos ... 12
2.1 Demo 1: Free Fall ... 12
2.2 Demo 2: Bullet Time ... 13
2.3 Demo 3: Bungee Jumping ... 14
2.4 Demo 4: Gimme ya Energy! ... 16
2.5 Demo 5: Magic Chain Cable ... 18
2.6 Demo 6: Heavy Chain Mail ... 20
2.7 Demo 7: Don’t Touch me! ... 22
2.8 Demo 8: Keep it up ... 23
2.9 Demo 9: Catch me if you Can (There’s a Hole in the Bucket) ... 25
2.10 Demo 10: The Hose ... 28
2.11 Demo 11: Polyhedrons ... 29
2.11.1 Number of Particles: 3 ... 33
2.11.2 Number of Particles: 4 ... 33
2.11.3 Number of Particles: 5 ... 33
2.11.4 Number of Particles: 6 ... 34
2.11.5 Number of Particles: 8 ... 34
2.11.6 Number of Particles: 12 ... 35
2.11.7 Number of Particles: 20 ... 35
2.12 Demo 12: Three-Body Eight ... 37
3 Mathematical Background ... 39
3.1 May the Force be with you ... 40
3.1.1 Gravity ... 40
3.1.2 Drag ... 41
3.1.3 Inertial Force ... 41
3.1.4 Attraction Force ... 41
3.1.5 Spring Force ... 43
3.1.6 Damping Force ...43
3.2 Differential Equations ... 45
4 Particle System Object ... 46
4.1 Class Definition particle_system ... 46
4.2 Properties particle_system ... 46
4.3 Constructor particle_system ... 47
4.4 Method get_particles_positions ... 48
4.5 Method get_particles_velocities ... 49
4.6 Methods kill_spring, kill_attraction ... 50
4.7 Method kill_particle ... 51
4.8 Method advance_time ...52
5 Particle System Object (Private Methods) ... 55
5.1 Private Method kill_old_particles ... 55
5.2 Private Method get_phase_space_state ... 56
5.3 Private Method compute_state_derivative ... 56
5.4 Private Method set_phase_space_state ... 57
5.5 Private Method aggregate_forces ... 58
5.6 Private Method clear_particle_forces ... 58
5.7 Private Method aggregate_spring_forces ... 59
5.8 Private Method aggregate attraction forces ... 61
5.9 Private Method aggregate_drag_forces ... 62
5.10 Private Method aggregate_gravity_forces ... 63
5.11 Private Method get_particle_accelerations ... 63
5.12 Private Method advance_particle_ages ... 64
5.13 Private Methods update_graphics_position ... 65
6 Particle Object ... 67
6.1 Class Definition and Properties particle ... 67
6.2 Constructor particle ... 67
6.3 Private Method append ... 68
6.4 Methods add_force, clear_force ... 69
6.5 Method delete ... 70
6.6 Method set.fixed ... 70
6.7 Method set.position ... 71
6.8 Method update_graphics_position ... 71
7 Spring Object ... 72
7.1 Class Definition and Properties spring ... 72
7.2 Constructor spring ... 72
7.3 Private Method append ... 73
7.4 Method delete ... 74
7.5 Method update_graphics_position ... 74
8 Attraction Object ... 75
A Vector Projection ... 76
B Particle System Dependency ... 77
C Particle, Attraction, and Spring Dependency ... 78
Introduction
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.
(Figure 1: 1988 Computer Animation ”Particle Dreams” [9] - contained in download version)
Today we simulate tens of thousands of particles in real-time on a single cpu (Figure 2) – even in a browser plugin (Figure 3) – 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 [3] can be used to produce such astonishingly addicting games as Falling Sand Game [6], sodaplay [10], BallDroppings [7], and Souptoys [13].
In 2006, Traer Bernstein [2] 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!
(Figure 2: Particle System API [5] - contained in download version)
(Figure 3: Flash 9 Particle System [1] - contained in download version)
(Figure 4: Souptoys [13] - contained in download version)
(Figure 5: Falling Sand Game [6] - contained in download version)
(Figure 6: Sodaplay [10] - contained in download version)
(Figure 7: BallDroppings [7] - contained in download version)
1 Genesis
The main purpose of this section is to give you a brief overview on how particles, springs, and attractions are created and implemented into the particle system.
1.1 Particle System Creation
Every particle system simulation begins with the creation of a particle system object1 that maintains and manages all particles, springs, and attractions
>> Particle_System = particle_system
gravity: [0 0 0 ]
drag: 0
particles: [ ]
springs: [ ]
attractions: [ ]
time: 0
graphics_handle: 1
The command particle_system opens an empty 3-D axes in a maximized window and creates an empty particle system with default properties
After the creation of the particle system object its properties can be defined
>> gravity = [0 0 -9.81];
and set
>> Particle_System.gravity = gravity
gravity: 0 0 -9.81
drag: 0
particles: [ ]
springs: [ ]
attractions: [ ]
time: 0
graphics_handle: 1
Please note that Matlab does not support passing arguments by reference. Therefore,
you have to pass the particle system object itself via parameter list and not forget to
use an assignment statement to reassign the updated object!
In many cases it might be more convenient to set all three particle system properties
(gravity, drag, and limits) directly during the creation of the object
>> Particle_System = particle_system ([0 0 -9.81] , 0, 1)
Particle System :
n_particles = 0
n_springs = 0
n_attractions = 0
gravity = 0 0 -9.81
drag = 0
limits = 1
time = 0
handle = 1
[...]
1 As a convention throughout this toolbox, Matlab objects names begin with uppercase letters.
Arbeit zitieren:
Prof. Dr.-Ing. Jörg Buchholz, 2008, Matlab Particles 2.0, München, GRIN Verlag GmbH
Dieser Text kann über folgende URL aufgerufen und zitiert werden:
Einbetten
DOI
Formatvorlage (Microsoft Word) für eine Diplomarbeit, Masterarbeit, Ha...
Für MS Word 2003 - Update 2010
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 25 Seiten
Formatvorlage (OpenOffice) für eine Diplomarbeit, Masterarbeit, Hausar...
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 35 Seiten
Formatvorlage / Vorlage zur Erstellung einer Diplomarbeit, Bachelorarb...
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 15 Seiten
Formatvorlage / Vorlage für eine Diplomarbeit / Hausarbeit
Für MS Word 2007 - dotx
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 25 Seiten
Anleitung zum Erstellen schriftlicher Arbeiten: Der Aufbau einer wisse...
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 20 Seiten
Erstellen einer schriftlichen Hausarbeit
Vorlagen, Muster, Formulare, Infobroschüren
Hausarbeit, 14 Seiten
Grundtechniken wissenschaftlichen Arbeitens
Bibliografieren - Reden - Schr...
Vorlagen, Muster, Formulare, Infobroschüren
Skript, 46 Seiten
Ratgeber zur Erstellung wissenschaftlicher Arbeiten. Diplomarbeiten - ...
Vorlagen, Muster, Formulare, Infobroschüren
Ausarbeitung, 39 Seiten
Jörg Buchholz hat den Text Matlab Particles 2.0 veröffentlicht
Jörg Buchholz hat einen neuen Text hochgeladen
MATLAB R2009, SIMULINK et STATEFLOW pour Ingénieurs, Chercheurs et Etu...
Nadia Martaj, Mohand Mokhtari
0 Kommentare