-
Notifications
You must be signed in to change notification settings - Fork 0
/
Living_Data_Project.pde
96 lines (59 loc) · 2.82 KB
/
Living_Data_Project.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
size(1800, 600);
background(10,30,50);
fill(139,200,125);
stroke(150,90,160);
Table myData;
myData = loadTable("collected_data.csv", "header");
int numRows = myData.getRowCount();
println("The number of rows in my table is:", numRows);
float maxSedentary = 0.0;
float maxSteps = 0.0;
float maxActivity = 0.0;
for (int i = 0; i < numRows; i++) {
float mySteps = myData.getRow(i).getFloat("Steps (average per min)");
maxSteps = max(mySteps, maxSteps);
}
println("The maximum Number of Steps that I had in one minute on average was:", maxSteps);
for (int i = 0; i < numRows; i++) {
float myActivity = myData.getRow(i).getFloat("Mean Activity (g)");
maxActivity = max(myActivity, maxActivity);
}
println("The maximum value for Mean Activty is:", maxActivity);
for (int i = 0; i < numRows; i++) {
beginShape();
int currentDay = myData.getRow(i).getInt("Day");
float xCoordinate = map (currentDay,0,6,110,width-110);
float centerX = xCoordinate;
float centerY = height/2;
float angle = map(i, 0, 24, 0, TWO_PI);
float avSteps = myData.getRow(i).getFloat("Steps (average per min)");
float mapSteps = map(avSteps,0,maxSteps,100,200);
float distanceOffset = 60;
float angleOffset = 30;
float distanceOffset2 = mapSteps;
float avActivity = myData.getRow(i).getFloat("Mean Activity (g)");
float mapActivity = map(avActivity,0,maxActivity,255,0);
float R = 255;
float G = mapActivity;
float B = 0;
fill(R,G,B);
float avSedentary = myData.getRow(i).getFloat("Sedentary Activity (proportion)");
float mapSedentary = map(avSedentary,1,maxSedentary,0,255);
float AR = mapSedentary;
stroke(AR,AR+100,200);
vertex(centerX, centerY);
float anchorPointx1 = centerX + distanceOffset * sin(angle + radians(angleOffset));
float anchorPointy1 = centerY + distanceOffset * cos(angle + radians(angleOffset));
float anchorPointx2 = centerX + distanceOffset2 * sin(angle);
float anchorPointy2 = centerY + distanceOffset2 * cos(angle);
float anchorPointx3 = centerX + distanceOffset * sin(angle - radians(angleOffset));
float anchorPointy3 = centerY + distanceOffset * cos(angle - radians(angleOffset));
float controlPointx = centerX + distanceOffset * sin(angle);
float controlPointy = centerY + distanceOffset * cos(angle);
bezierVertex(controlPointx, controlPointy, controlPointx, controlPointy, anchorPointx1, anchorPointy1);
bezierVertex(controlPointx, controlPointy, controlPointx, controlPointy, anchorPointx2, anchorPointy2);
bezierVertex(controlPointx, controlPointy, controlPointx, controlPointy, anchorPointx3, anchorPointy3);
bezierVertex(controlPointx, controlPointy, controlPointx, controlPointy, centerX, centerY);
endShape();
}
save("output.png");