Thank you for reading this.
I’ve spent most of the day on this and although the code basically works the result is pretty rough. Can anyone suggest how I might smooth out the resulting curve?
float a = 0.0;
float inc = TWO_PI/25.0; // I don't understand why the inc value is 2*Pi / 25.
float prev_x = 0, prev_y = 50, x, y;
void setup()
{
size(400, 200);
stroke(255, 0, 0);
noLoop();
}
void draw()
{
for (int i=0; i<160; i=i+5)
{
//x = i;
y = 50 + cos(a *3) * 40.0; // 3 times the frequency of the x axis
x = 50 + sin(a) * 40.0;
line(prev_x, prev_y, x, y);
prev_x = x;
prev_y = y;
a = a + inc;
}
}