-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParticle.pde
More file actions
55 lines (46 loc) · 1.48 KB
/
Particle.pde
File metadata and controls
55 lines (46 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
boolean record;
import processing.dxf.*;
class Particle {
//create PVectors
PVector[] location= new PVector[numOfLines];
PVector[] velocity= new PVector[numOfLines];
Particle() {
//create points at 0,0,0
for (int i = 0; i < numOfLines; ++i) {
float x = (i*2)*sin(i/5.0);
float y = (i*2)*cos(i/5.0);
float z = 0;
location[i] = new PVector(x,y,z);
}
// create velocities for each point
for (int i = 0; i < numOfLines; ++i) {
float x = random(-0.05,0.05);
float y = random(-0.05,0.05);
float z = random(-0.05,0.05);
velocity[i] = new PVector(x, y,z);
}
}
void update() {
//add the velocity to each point every frame
for (int i = 0; i < numOfLines; ++i) {
location[i].x = location[i].x += velocity[i].x;
location[i].y = location[i].y += velocity[i].y;
location[i].z = location[i].z += velocity[i].z;
float x = location[i].x;
float y = location[i].y;
float z = location[i].z;
}
draw();
}
void draw(){
//add a random value to the velocity each frame
// for (int i = 0; i < numOfLines; ++i) {
// float x = random(-0.05,0.05);
// float y = random(-0.05,0.05);
// float z = random(-0.05,0.05);
// velocity[i].x = velocity[i].x += x *0.01;
// velocity[i].y = velocity[i].y += y *0.01;
// velocity[i].z = velocity[i].z += z *0.1;
// }
}
}