通过增加频率处理绘制正弦波

Draw sine wave with increasing frequency processing

我有以下绘制正弦波的代码。 请参阅下面的代码:

float x, y;
float prevX=0.0, prevY=0.0;
int numOfWaves = 6;
float angle = 0;

void setup()
{
  size(360, 360);
  background(0);
  smooth();
  stroke(255);
}

void draw()
{
  translate(0, height/2);
  scale(1, -1);

  for(int count=0; count < 360; ++count){
    x = count;

    angle = radians(count);
    y = sin(angle*(numOfWaves/2.0));

    y = map(y,-1,1,-height/2,height/2);

    line(prevX, prevY, x, y);

    prevX = x;
    prevY = y;
  }

  prevX = prevY = 0.0;
}

但我希望正弦波的频率随着距离的增加而增加。 这是我得到的电流正弦波:

但我想让它看起来像这样:

我该怎么做?

你知道如何绘制 sin(2*π*f*t)

A​​ "chirp" 的频率本身就是时间的函数:

y(t) = A*sin(2*π*f(t)*t)

其中 f(t) 可以是线性的、二次的或您选择的任何其他形式。