noise generator does'n work for me

Hi guys,

I've found this link http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1191768812 where 2 exemples of perlin noise generator are posted. Unfortunately I don't know why I couldn't manage to get them work whit my board. The first one for exemple always return me a value of 80.

any help will be apperciate

j_derius:
...The first one for exemple always return me a value of 80.

The code posted in the first example was (obviously) not tested.

Here's the Noise2() function from that post:

//using the algorithm from http://freespace.virgin.net/hugo.elias/models/m_perlin.html
// thanks to hugo elias
float Noise2(float x, float y)
{
  long noise;
  noise = x + y * 57;
  noise = pow(noise << 13,noise); //<---- This is the bug
  return ( 1.0 - ( long(noise * (noise * noise * 15731L + 789221L) + 1376312589L) & 0x7fffffff) / 1073741824.0);
}

The code should have been

float Noise2(float x, float y)
{
    long noise;
    noise = x + y * 57;
    noise = (noise << 13) ^ noise; // <--- exclusive-or, not power!
    return ( 1.0 - ( long(noise * (noise * noise * 15731L + 789221L) + 1376312589L) & 0x7fffffff) / 1073741824.0);
}

Regards,

Dave

Footnote:
The original pseudocode by Hugo Elias can be found at http://freespace.virgin.net/hugo.elias/models/m_perlin.htm (Note that it is .htm, not .html shown in the Mike Edwards comment.)

[/begin disclaimer]
I have not evaluated the results so I don't know whether or not there were bugs in the original from Hugo Elias, and I don't know whether there are other bugs in the implementation by Mike Edwards.
[/end disclaimer]

Regards,

Dave

wow,
thanks a lot Dave it works !!!! :slight_smile: