-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFractal_de_Koch_prueba4.pde
119 lines (79 loc) · 2.1 KB
/
Fractal_de_Koch_prueba4.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//import processing.video.*;
import TUIO.*;
import spout.*;
Spout spout;
TuioProcessing tuioClient;
TuioObject tobj;
ArrayList<TuioObject> tuioObjectList;
ArrayList<KochLine> lines ;
boolean softLines;
int niveles;
int ID;
int cuadros;
int[] PosX = {
0, 0, 0, 0, 0
};
int [] PosY= {
0, 0, 0, 0, 0
};
//---------------------------
void setup() {
//fullScreen(2);
size( 800, 600, P3D );
frameRate(25);
smooth();
imageMode(CENTER);
tuioClient = new TuioProcessing(this);
spout = new Spout(this);
spout.createSender("Spout Processing");
}
//---------------------------
void draw() {
background(0);
buscarPosicion();
lines = new ArrayList<KochLine>();
PVector a = new PVector(PosX[0],PosY[0]);
PVector b = new PVector(PosX[1],PosY[1]);
// PVector c = new PVector((dist(PosX[0], PosY[0], PosX[1], PosY[1])/2), (dist(PosX[0], PosY[0], PosX[1], PosY[1]))*cos(radians(30)));
PVector c = new PVector(PosX[2],PosY[2]);
// Starting with additional lines
lines.add(new KochLine(a, b));
lines.add(new KochLine(b, c));
lines.add(new KochLine(c, a));
cuantosTengo();
for (int i = 0; i < niveles; i++) {
generate();
}
for (KochLine l : lines) {
l.display();
}
buscarPosicion();
}
void generate() {
ArrayList next = new ArrayList<KochLine>(); // Create emtpy list
for (KochLine l : lines) {
// Calculate 5 koch PVectors (done for us by the line object)
PVector a = l.kochA();
PVector b = l.kochB();
PVector c = l.kochC();
PVector d = l.kochD();
PVector e = l.kochE();
// Make line segments between all the PVectors and add them
next.add(new KochLine(a, b));
next.add(new KochLine(b, c));
next.add(new KochLine(c, d));
next.add(new KochLine(d, e));
}
lines = next;
spout.sendTexture();
}
//---------------------------
void removeTuioObject(TuioObject tobj) {
int IDremove=tobj.getSymbolID();
if (IDremove<=5) {
PosX[IDremove]=0;
PosY[IDremove]=0;
println("El objeto " + IDremove + " fue eliminado");
}
}
//---------------------------