wnoise function

double wnoise(
  1. double x,
  2. int period, [
  3. int seed = 0
])

1D value noise in -1, 1 whose lattice wraps every period cells.

Implementation

double wnoise(double x, int period, [int seed = 0]) {
  final i = x.floor();
  final f = x - i;
  final u = f * f * (3.0 - 2.0 * f);
  final a = rand(wrapInt(i, period), seed);
  final b = rand(wrapInt(i + 1, period), seed);
  return (a + (b - a) * u) * 2.0 - 1.0;
}