Hello,
I would like to endShape and begin a new one based off a numeric value from a data set. I would like each separate shape to also have a different rotation value based off of the same numeric value. My current code draws it as one shape instead of multiple separate ones. Thinking something like an if statement outside of beginShape();? Later, the data table will be more complex but wanting to begin with simplified values. Thanks in advance!
Here is my current code:
import peasy.*;
Table myTable;
int numEntries;
float x;
float y;
float z;
PeasyCam cam;
void setup(){
size(600, 600,P3D);
point(width/2,height/2);
cam = new PeasyCam(this,1000);
myTable = loadTable("data-test.csv", "header");
numEntries = myTable.getRowCount();
}
void draw(){
background(225);
beginShape();
for (int i = 0; i < numEntries; i++) {
x = myTable.getRow(i).getFloat("Hour");
println("#:", x);
y = myTable.getRow(i).getFloat("Rating Level");
println("rating height", y);
//would like to use "Day" value to tell to end and begin a new shape.
//For example, when Day = 1 I want to begin a shape.
//When Day = 2, I want to end the previous shape and begin a new one.
//Each one of these shapes will have a different rotation value (zrot variable below)
z = myTable.getRow(i).getFloat("Day");
println("day", z);
println("_");
float zrot = map(z, 0, 5, 0, TWO_PI);
//angle plays in with x/y coord below
float angle = map(x, 1, 12, 0, PI);
float xCenter = width/2;
float yCenter = height/2;
float xCoord = xCenter + cos(angle-(PI)) * (y);
float yCoord = yCenter + sin(angle-(PI)) * (y);
vertex(xCoord, yCoord);
//rotates around z axis based on day #
rotateZ(zrot*10);
}
endShape();
}
Here is my data information in csv formatting.
Day,Hour,Rating Level
1,1,50
1,2,100
1,3,50
1,4,100
1,5,50
1,6,100
1,7,50
1,8,100
1,9,50
1,10,100
1,11,50
1,12,100
2,1,30
2,2,90
2,3,30
2,4,90
2,5,30
2,6,90
2,7,30
2,8,90
2,9,30
2,10,90
2,11,30
2,12,90
3,1,50
3,2,100
3,3,50
3,4,100
3,5,50
3,6,100
3,7,50
3,8,100
3,9,50
3,10,100
3,11,50
3,12,100
4,1,30
4,2,90
4,3,30
4,4,90
4,5,30
4,6,90
4,7,30
4,8,90
4,9,30
4,10,90
4,11,30
4,12,90