-
Notifications
You must be signed in to change notification settings - Fork 0
/
ModelFactory.pde
74 lines (62 loc) · 1.8 KB
/
ModelFactory.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
Model triangle_model(float radius) {
Model model = new Model(radius);
for (int i = 0; i < 3; ++i) {
model.addPoint(polarPoint(radius, i * TWO_PI / 3));
}
return model;
}
Model square_model(float radius) {
Model model = new Model(radius);
for (int i = 0; i < 4; ++i) {
model.addPoint(polarPoint(radius, i * TWO_PI / 4));
}
return model;
}
Model rectangle_model(float radius) {
Model model = new Model(radius);
model.addPoint(polarPoint(radius, TWO_PI / 16));
model.addPoint(polarPoint(radius, PI - TWO_PI / 16));
model.addPoint(polarPoint(radius, PI + TWO_PI / 16));
model.addPoint(polarPoint(radius, TWO_PI - TWO_PI / 16));
return model;
}
Model pentagon_model(float radius) {
Model model = new Model(radius);
for (int i = 0; i < 5; ++i) {
model.addPoint(polarPoint(radius, i * TWO_PI / 5));
}
return model;
}
Model hexagon_model(float radius) {
Model model = new Model(radius);
for (int i = 0; i < 6; ++i) {
model.addPoint(polarPoint(radius, i * TWO_PI / 6));
}
return model;
}
Model star_model(float radius) {
Model model = new Model(radius);
for (int i = 0; i < 5; ++i) {
model.addPoint(polarPoint(radius, i * TWO_PI / 5));
model.addPoint(polarPoint(radius / 2, i * TWO_PI / 5 + TWO_PI / 10));
}
return model;
}
Model cardioid_model(float radius) {
int VERTICES = 32;
Model model = new Model(radius);
for (float t = 0; t < TWO_PI; t += TWO_PI / VERTICES) {
float r = radius / 2 * (1 - cos(t));
model.addPoint(polarPoint(r, t));
}
return model;
}
Model blobbie_model(float radius) {
int VERTICES = 32;
Model model = new Model(radius);
for (float t = 0; t < TWO_PI; t += TWO_PI / VERTICES) {
float r = radius * 4 / 7 * (1 + 0.25*cos(2*t + 5) + 0.5*cos(3*t));
model.addPoint(polarPoint(r, t));
}
return model;
}