-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvGroup.pde
72 lines (61 loc) · 1.71 KB
/
vGroup.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
61
62
63
64
65
66
67
68
69
70
71
72
class vGroup {
int noLines;
int noPoints;
float factor;
float offset;
float spacing;
float[] angle = {HALF_PI, QUARTER_PI, TWO_PI, -QUARTER_PI, - HALF_PI};
ArrayList<vLine> vLines = new ArrayList<vLine>();
vGroup(int nl, int np, float fc, float of, float sp) {
noLines = nl;
noPoints = np;
factor = fc;
offset = of;
spacing = sp;
}
void construct(float max_height, float max_depth, int hue) {
float pointZ = 0;
// Loop for each Vector Line
for (int y = 0; y < noLines; y++) {
float pointX = 0;
vLine vln = new vLine(hue);
// Loop for all points of Vector Line
for (int x = 0; x < noPoints; x++) {
// next angle is based on noise (therefore previous) choice of 5 angles
int n = int(round(map(noise(x * factor + offset, y * factor + offset), 0, 1, 0, 5)));
if (n > 4) {
n = 4;
}
// Distance vector (higher mag results in longer line between 2 points)
PVector d = PVector.fromAngle(angle[n]).setMag(3);
// Increase next point by distance components
pointX += d.x;
pointZ += d.y;
// Invert distance when condition is met
if (pointZ > max_height || pointZ < max_depth) {
pointZ -= d.y;
}
// Add points to vLine object
vln.pts.add(new PVector(pointX, y * spacing, pointZ));
}
// Store vLine object in array //<>//
vLines.add(vln);
// Reset for next vLine
pointZ = 0;
}
}
void show() {
if (vLines != null) {
for (vLine vl : vLines) {
vl.show();
}
}
}
void animate() {
if (vLines != null) {
for (vLine vl : vLines) {
vl.animate();
}
}
}
}