math icon indicating copy to clipboard operation
math copied to clipboard

noise1 output range seems to be [-0.631 0.631] instead of [-1 1]

Open pbaille opened this issue 9 years ago • 6 comments


( (juxt (partial apply min)(partial apply max))
  (take 100000 (map noise1 (iterate (partial + (rand)) (rand 100000)))))
;;=> [-0.6310094734594794 0.631009462592625]

maybe NORM const should be accessible to the user?

pbaille avatar Feb 09 '16 15:02 pbaille

is it normal that it output exactly 0 more than 10% of the time?

(count (filter zero? (take 100000 (map noise1 (iterate (partial + (rand)) (rand 100000)))))) 
;;=> 10548

pbaille avatar Feb 09 '16 15:02 pbaille

Investigating, thanks for letting me know....

postspectacular avatar Feb 10 '16 01:02 postspectacular

Just for reference this code was ported from this OpenCL version here: https://github.com/terrybroad/Simplex_Noise_OpenCL/blob/master/Simplex_Noise.cl

postspectacular avatar Feb 10 '16 01:02 postspectacular

Just updated (and optimized) these functions, but still not 100% sure where the scaling issue is coming from (actually might be already present in the original version this code is based on). Also have added some images and renamed the namespace to thi.ng.math.noise (since I will add more noise gens, the current one is actually gradient noise, not the simplex noise, which is still waiting to be ported).

I removed the final normalization step from all fns, but noise1 now has a range of -1 .. +1. noise2 and noise3 seem to go from -1 .. +0.89....

https://github.com/thi-ng/math/blob/master/src/noise.org

postspectacular avatar Mar 09 '16 19:03 postspectacular

great! I will take a look as soon as possible

pbaille avatar Mar 09 '16 21:03 pbaille

let's maybe not close this just yet... also, if you want to play around w/ it, use the [thi.ng/math "0.2.0-SNAPSHOT"]

postspectacular avatar Mar 09 '16 21:03 postspectacular