Particle
Introduction
Particle
Ein Partikel ist ein "kleines Teilchen, z.B. mikroskopisch kleines
Wassertröpfchen im nebel(...)."
Partikelsysteme werde häufig in der computeranimation
verwendet, um eine große Anzahl von objekte zu animieren.
Eine Kombination von Bewegunsparametern mit bestimmten
Materialeigenschaften ermöglichen Beispielsweise
die realistische Simulation von Feuer, Rauch oder auch
Haaren.
Arrays Eine Array ist eine Art Liste, in welcher mehrere Instanzen vom gleichen Datentyp zwischengespeichert werden kann. Im Gegensatz zu den Dynamischen Arrays, muss beim Erstellen bereits die Größe des Arrays festliegen, d.h. wie viele Einträge in die Liste gespeichert werden sollen. Bei Arrays sind die einzelnen Instanzen bzw. Listeneinträge jeweils über einen Indexwert erreichbar, d.h. die Reihenfolge der Einträge spielt eine wichtige Rolle.
/* Steps for creating an array:
01. Create the array with a certain name and datatype. Between datatype and name should be the brackets []. The square brackets always mark arrays.
02. Give the array a size (size = how much data you want to save with it)
03. Give the array content. All content must be the same values as the datatype defined in the array
04. Every content has a certain position in the array. If you want to fill the array, you need to say at which position you want to put it
05. You can access every position in the array (and its content) by writing the name of the array followed by square brackets with the index position in the array.
*/
color colors; /* define an array with name colors */
colors = new color [3]; /* give the array a size */
colors [0] = color (45, 47, 35); /* give every position in the array a content, every array starts with the position 0 */
colors [1] = color (235);
colors [2] = color (240, 20, 20);
Dynamische Arrays Dynamische Arrays übernehmen die selbe Aufgabe wie einfache Arrays. Der einzige Unterschied ist, dass beim Erstellen die Größe des Arrays nicht festliegen muss. Das bedeutet, dass innerhalb des Programmes Daten dynamisch hinzugefügt oder wieder entfernt werden können. Der Nachteil gegenüber den Arrays ist, dass die »Liste« mehr Speicherplatz verbraucht, da jedes Mal, wenn ein Objekt hinzugefügt wird neuer Speicherplatz allokiert werden muss.
ArrayList
position = new ArrayList (); /* start a new ArrayList */
position.add (new PVector (0, 0));/* add a new instance of the gives datatypes. No primitives allowed. The new object will be added at the end of the list*/
position.remove (3);/* remove an object of the list at the position 3 */
Exercises
Arrays
Get the Code: array.pde
Get the Code: arraylist.pde
Particle
Get the Code: vectors_01.pde
Get the Code: vectors_02.pde
Get the Code: vectors_03.pde
Get the Code: vectors_04.pde
Vector Fields
Get the Code: vectorfield.pde
Trigonometrie
Get the Code: objectsAroundCircle.pde
Connections
Links
-
Vectors >
natureofcode
.com/ book/ chapter-1- vectors/ -
Particle Systems >
natureofcode
.com/ book/ chapter-4- particle- systems/ -
Particle Definition >
en.wikipedia
.org /wiki /Particle -
Arrays >
www.creativecoding
.org/ lesson/ basics/ processing/ arrays -
OOP >
www.creativecoding
.org/ lesson/ basics/ processing/ objekte