Hello,
I am trying to draw a shape, like a cylinder, but the output is something like this:
As you see, the last point is not matching the first point and I can’t figure out what I am doing wrong.
Here is the code for this:
int rows = 12;
int cols = 7;
void setup()
{
size(1200, 800, P3D);
}
void draw()
{
background(0);
beginCamera();
camera();
rotateX(87);
endCamera();
lights();
float angle = 0;
stroke(255);
fill(255, 0, 0);
translate(width/2, height/2, 0.0);
strokeWeight(2);
stroke(0);
for(int i = 0; i < rows - 1; i++)
{
beginShape(TRIANGLE_STRIP);
for(int j = 0; j < cols; j++)
{
angle += TWO_PI/cols;
vertex(j * 50 * sin(angle), i * 50, 50 * cos(angle));
vertex(j * 50 * sin(angle), (i + 1) * 50, 50 * cos(angle));
println("V1 -> X: " + j * 50 * sin(angle) + " Y: " + i * 50 + " Z: " + 50 * cos(angle));
println("V2 -> X: " + j * 50 * sin(angle) + " Y: " + (i + 1) * 50 + " Z: " + 50 * cos(angle));
}
endShape();
}
}
Hope you can help me solve this problem.
Thank you!