-
Notifications
You must be signed in to change notification settings - Fork 0
/
Particle.pde
60 lines (49 loc) · 1 KB
/
Particle.pde
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
56
57
58
59
60
class Particle {
float id;
PVector pos;
PVector cons_pos;
PVector vel;
float invmass = 0.1;
PVector forces;
boolean fixed;
PImage img;
Particle(PVector p) {
vel = new PVector(0,0,0);
forces = new PVector(0,0,0);
pos = p.copy();
cons_pos = p.copy();
fixed = false;
}
Particle(PVector p, boolean fix, float pid) {
vel = new PVector(0,0,0);
forces = new PVector(0,0,0);
pos = p.copy();
cons_pos = p.copy();
fixed = fix;
id = pid;
}
void run() {
render();
}
// Method to apply a force vector to the Particle object
// Note we are ignoring "mass" here
void applyForce(PVector f) {
forces.add(f);
}
// Method to display
void render() {
int color_value;
if (fixed) {
color_value = 100;
} else {
color_value = 255;
}
pushMatrix();
translate(pos.x, pos.y, pos.z);
lights();
noStroke();
fill(color_value);
sphere(2);
popMatrix();
}
}