singleSimplex2 method
Implementation
double singleSimplex2(int seed, int x, int y) {
var t = (x + y) * _f2;
final i = x + t.floor();
final j = y + t.floor();
t = (i + j) * _g2;
final x0 = x - (i - t);
final y0 = y - (j - t);
final int i1;
final int j1;
if (x0 > y0) {
i1 = 1;
j1 = 0;
} else {
i1 = 0;
j1 = 1;
}
final x1 = x0 - i1 + _g2;
final y1 = y0 - j1 + _g2;
final x2 = x0 - 1 + _f2;
final y2 = y0 - 1 + _f2;
final double n0;
final double n1;
final double n2;
t = 0.5 - x0 * x0 - y0 * y0;
if (t < 0) {
n0 = .0;
} else {
t *= t;
n0 = t * t * gradCoord2D(seed, i, j, x0, y0);
}
t = 0.5 - x1 * x1 - y1 * y1;
if (t < 0) {
n1 = .0;
} else {
t *= t;
n1 = t * t * gradCoord2D(seed, i + i1, j + j1, x1, y1);
}
t = 0.5 - x2 * x2 - y2 * y2;
if (t < 0) {
n2 = .0;
} else {
t *= t;
n2 = t * t * gradCoord2D(seed, i + 1, j + 1, x2, y2);
}
return 50 * (n0 + n1 + n2);
}