【发布时间】:2017-04-30 23:14:54
【问题描述】:
我有以下绘制正弦波的代码。 请参阅下面的代码:
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;
}
但我希望正弦的频率随着距离的增加而增加。 这是我得到的当前正弦波:
我该怎么做?
【问题讨论】:
-
在最后一张图中,当您从左向右移动时,频率降低,而波长增加。这是您想要的,还是您希望频率向右增加,还是在图形的一端之外发生了其他事情?
标签: math processing frequency