Flat Sided Circle Problem
in
Programming Questions
•
1 year ago
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;
- vertex( x,y );
- print ("i: "+i+" "+x+","+y+"\n");
- }
- endShape(CLOSE);
- }
1