noise() doesn't give me a wide range of values
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 alm开发者_StackOverflowost 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?
You might adjust the noiseDetail()
to include more than 4 octaves
or to use a falloff
below 0.5.
精彩评论