I am trying to use triangle fan to cap the ends of the cylinder I am creating. I have simplified the code below to what is causing the problem. For some reason triangle_fan wants to create a "phantom" face. 15 faces are drawn but the count reads 16.
This can be isolated to show the "phantom face" if change line 37 to read: Somehow it is drawing a face from only two points.
for ( int i = 0; i < 1; i++ ) {
The code below is what I am having problems with. Any help would be greatly appreciated.
I am trying to do a simple code to draw a multisided circle using the code below. For some reason, a flat side starts to form in my circle and I am not sure why. It is pretty obvious when the number of sides is 19.
Any thoughts?
void setup() {
int sides = 18;
size(800,800);
drawCylinder(400,400,sides,200);
}
void drawCylinder(int orginX, int orginY, int sides, float r) {
float angle = 360 / sides;
beginShape();
for(int i = 0; i < sides; i++) {
float x = (cos( radians ( i * angle ) ) * r)+ orginX;
float y = (sin( radians ( i * angle ) ) * r)+ orginY;