Random starting Angle to finish Circle

The condition a < TWO_PI + a will of course always evaluate to true.

Why not first choose a random starting angle, like this?:

  float start_angle = random(0, TWO_PI);

With that, you can write the program as follows:

void setup() {
  size(400, 400);
}
void draw() {
  translate(width/2, height/2);
  noFill();
  beginShape();
  float r = 100;
  float start_angle = random(0, TWO_PI);
  for (float a = 0; a < TWO_PI; a += 0.02) {
     float x = r * cos(a + start_angle);
     float y = r * sin(a + start_angle);
     vertex(x, y);
    }
  endShape();
}
2 Likes