noise2 method

  1. @override
double noise2(
  1. double x,
  2. double y
)
override

Implementation

@override
double noise2(double x, double y) {
  int x0 = floor(x);
  int y0 = floor(y);
  int x1 = x0 + 1;
  int y1 = y0 + 1;
  double xs = 0, ys = 0, zs = 0;
  xs = interpHermiteFunc(x - x0);
  ys = interpHermiteFunc(y - y0);
  double xd0 = x - x0;
  double yd0 = y - y0;
  double xd1 = xd0 - 1;
  double yd1 = yd0 - 1;
  double xf00 = lerp(gradCoord2D(seed, x0, y0, xd0, yd0),
      gradCoord2D(seed, x1, y0, xd1, yd0), xs);
  double xf10 = lerp(gradCoord2D(seed, x0, y1, xd0, yd1),
      gradCoord2D(seed, x1, y1, xd1, yd1), xs);
  double xf01 = lerp(gradCoord2D(seed, x0, y0, xd0, yd0),
      gradCoord2D(seed, x1, y0, xd1, yd0), xs);
  double xf11 = lerp(gradCoord2D(seed, x0, y1, xd0, yd1),
      gradCoord2D(seed, x1, y1, xd1, yd1), xs);
  double yf0 = lerp(xf00, xf10, ys);
  double yf1 = lerp(xf01, xf11, ys);
  return lerp(yf0, yf1, zs);
}