math
math copied to clipboard
noise1 output range seems to be [-0.631 0.631] instead of [-1 1]
( (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?
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
Investigating, thanks for letting me know....
Just for reference this code was ported from this OpenCL version here: https://github.com/terrybroad/Simplex_Noise_OpenCL/blob/master/Simplex_Noise.cl
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
great! I will take a look as soon as possible
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"]