噪音()没有给我很大范围的值
我今天试图使用噪声在处理中生成伪随机角度,但它没有像我希望的那样工作。
float xoff = 0;
float inc = 0.01;
void draw(){
float vx = cos( noise(xoff) * 2 * PI));
xoff += inc;
}
这是我的代码的重要部分。我认为会发生的是 vx 将是 -1 和 1 之间的随机浮点数,但它几乎总是负数。问题似乎在于噪声(xoff)输出的值范围有限。仅在 0.3 至 0.7 之间。要使 vx 为正值,它需要低于 0.3 且高于 0.7,但这几乎不会发生。
这里出了什么问题?
I was trying to generate a pseudo-random angle in processing today using noise but it is not working as I would have hoped.
float xoff = 0;
float inc = 0.01;
void draw(){
float vx = cos( noise(xoff) * 2 * PI));
xoff += inc;
}
This is the important part of my code. What I thought would happen was that vx would be a random float between -1 and 1 but it is almost always negative. What seems to be the problem is that the noise(xoff) is outputting a limited range of values. Only between 0.3 and 0.7. For vx to be positive it needs to be lower than 0.3 and higher than 0.7, but this never almost never happens.
What is going wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以调整
noiseDetail()
以包含超过 4 个八度
或使用低于0.5的衰减
。You might adjust the
noiseDetail()
to include more than 4octaves
or to use afalloff
below 0.5.