
I am trying to implement a basic pelin noise function, but I have some problem with the integer to noise function used to generate deterministic noise from integer inputs. the function I am trying to implement is defined there: http://libnoise.sourceforge.net/noisegen/index.html#continuousnoise and my code so far look like this: noise2d :: (Int32, Int32) -> Double noise2d (x, y) = let m = x + y * 57 n = (shiftR m 13) ^ m j = (n * (n * n * 15731 + 789221) + 1376312589) .&. 0x7fffffff in 1.0 - (fromIntegral j / 1073741824.0) the code compile but I get the same result for any input, due to the fact that n is evaluated to 0. Is there a better way to do that?

Got it, the error was coming from me thinking of the C "^" operator as
exponent, instead of bitwise xoring.
On Wed, Apr 22, 2015 at 3:39 PM, Florian Gillard
I am trying to implement a basic pelin noise function, but I have some problem with the integer to noise function used to generate deterministic noise from integer inputs.
the function I am trying to implement is defined there: http://libnoise.sourceforge.net/noisegen/index.html#continuousnoise
and my code so far look like this:
noise2d :: (Int32, Int32) -> Double noise2d (x, y) = let m = x + y * 57 n = (shiftR m 13) ^ m j = (n * (n * n * 15731 + 789221) + 1376312589) .&. 0x7fffffff in 1.0 - (fromIntegral j / 1073741824.0)
the code compile but I get the same result for any input, due to the fact that n is evaluated to 0.
Is there a better way to do that?

On Wed, Apr 22, 2015 at 8:39 PM, Florian Gillard
I am trying to implement a basic pelin noise function, but I have some problem with the integer to noise function used to generate deterministic noise from integer inputs.
the function I am trying to implement is defined there: http://libnoise.sourceforge.net/noisegen/index.html#continuousnoise
I understand you're trying to transcribe an algorithm given in C into Haskell. That's a great way to learn. In fact, if you zoom out a bit, there's more to explore in the various prng libraries on hackage. For it so happens that the exact function you cited is a prng, one of many. -- Kim-Ee
participants (2)
-
Florian Gillard
-
Kim-Ee Yeoh