Maths question relating to TAU

The following code plots a circle which is going to be a path for an image or a Pshape to follow. Where I’ve used a = (i * TAU) / 90 seems a bit clumsy and I’m wondering if anyone can suggest what I should have done here?

void setup()
{
  size(400, 200);
  stroke(255, 0, 0);
  strokeWeight(2);
  background(204);

  timeEnd = millis();
}

float x = 0.0;
float y = 0.0;
float a = 0.0;
int i = 0;
int timeEnd;

void draw()
{
  if (millis() > timeEnd + 100)
  {
    timeEnd = millis();

    i += 1;
    //if (i > 90)
    //{
    //  i = 0;
    //}  
    a = (i * TAU) / 90;
    x = (sin(a) * 50) + 60;
    y = (cos(a) * 50) + 60;

    point(x, y);    
    println("x = ", x, "y = ", y);
  }
}

Hello,

You are moving in 4 deg steps with TAU/90.

Try TAU/360 for 1 deg steps.

:)

1 Like