@Override public double getValue(double x, double y, double z) { int ix = Utils.floor(Utils.makeInt32Range(x)); int iy = Utils.floor(Utils.makeInt32Range(y)); int iz = Utils.floor(Utils.makeInt32Range(z)); return ((ix & 1 ^ iy & 1 ^ iz & 1) != 0) ? -1.0 : 1.0; } }
zs = (z - z0); } else if (quality == NoiseQuality.STANDARD) { xs = Utils.sCurve3(x - x0); ys = Utils.sCurve3(y - y0); zs = Utils.sCurve3(z - z0); } else { xs = Utils.sCurve5(x - x0); ys = Utils.sCurve5(y - y0); zs = Utils.sCurve5(z - z0); n0 = valueNoise3D(x0, y0, z0, seed); n1 = valueNoise3D(x1, y0, z0, seed); ix0 = Utils.linearInterp(n0, n1, xs); n0 = valueNoise3D(x0, y1, z0, seed); n1 = valueNoise3D(x1, y1, z0, seed); ix1 = Utils.linearInterp(n0, n1, xs); iy0 = Utils.linearInterp(ix0, ix1, ys); n0 = valueNoise3D(x0, y0, z1, seed); n1 = valueNoise3D(x1, y0, z1, seed); ix0 = Utils.linearInterp(n0, n1, xs); n0 = valueNoise3D(x0, y1, z1, seed); n1 = valueNoise3D(x1, y1, z1, seed); ix1 = Utils.linearInterp(n0, n1, xs); iy1 = Utils.linearInterp(ix0, ix1, ys); return Utils.linearInterp(iy0, iy1, zs);
int index0 = Utils.clamp(indexPos - 2, 0, lastIndex); int index1 = Utils.clamp(indexPos - 1, 0, lastIndex); int index2 = Utils.clamp(indexPos, 0, lastIndex); int index3 = Utils.clamp(indexPos + 1, 0, lastIndex); return Utils.cubicInterp(controlPoints.get(index0).outputValue, controlPoints.get(index1).outputValue, controlPoints.get(index2).outputValue, controlPoints.get(index3).outputValue, alpha);
int index0 = Utils.clamp(indexPos - 1, 0, controlPointCount - 1); int index1 = Utils.clamp(indexPos, 0, controlPointCount - 1); return Utils.linearInterp(value0, value1, alpha);
alpha = Utils.sCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve)); return Utils.linearInterp(sourceModule[0].getValue(x, y, z), sourceModule[1].getValue(x, y, z), alpha); } else if (controlValue < (upperBound - edgeFalloff)) { alpha = Utils.sCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve)); return Utils.linearInterp(sourceModule[1].getValue(x, y, z), sourceModule[0].getValue(x, y, z), alpha); } else {
@Override public double getValue(double x, double y, double z) { double z1 = z; double x1 = x; x1 *= frequency; z1 *= frequency; double distFromCenter = Math.sqrt(x1 * x1 + z1 * z1); double distFromSmallerSphere = distFromCenter - Utils.floor(distFromCenter); double distFromLargerSphere = 1.0 - distFromSmallerSphere; double nearestDist = Math.min(distFromSmallerSphere, distFromLargerSphere); return 1.0 - (nearestDist * 4.0); // Puts it in the -1.0 to +1.0 range. } }
nx = Utils.makeInt32Range(x1); ny = Utils.makeInt32Range(y1); nz = Utils.makeInt32Range(z1);
/** * Returns the output value from the noise module given the (latitude, longitude) coordinates of the specified input value located on the surface of the sphere. * * @param lat The latitude of the input value, in degrees. * @param lon The longitude of the input value, in degrees. * @return The output value from the noise module. */ public double getValue(double lat, double lon) { if (module == null) { throw new NoModuleException(); } double[] vec = Utils.latLonToXYZ(lat, lon); return module.getValue(vec[0], vec[1], vec[2]); } }
@Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null) { throw new NoModuleException(); } if (sourceModule[1] == null) { throw new NoModuleException(); } if (sourceModule[2] == null) { throw new NoModuleException(); } double v0 = sourceModule[0].getValue(x, y, z); double v1 = sourceModule[1].getValue(x, y, z); double alpha = sourceModule[2].getValue(x, y, z); return Utils.linearInterp(v0, v1, alpha); } }
zs = (z - (double) z0); } else if (quality == NoiseQuality.STANDARD) { xs = Utils.sCurve3(x - (double) x0); ys = Utils.sCurve3(y - (double) y0); zs = Utils.sCurve3(z - (double) z0); } else { xs = Utils.sCurve5(x - (double) x0); ys = Utils.sCurve5(y - (double) y0); zs = Utils.sCurve5(z - (double) z0); n0 = gradientNoise3D(x, y, z, x0, y0, z0, seed); n1 = gradientNoise3D(x, y, z, x1, y0, z0, seed); ix0 = Utils.linearInterp(n0, n1, xs); ix1 = Utils.linearInterp(n0, n1, xs); iy0 = Utils.linearInterp(ix0, ix1, ys); n0 = gradientNoise3D(x, y, z, x0, y0, z1, seed); n1 = gradientNoise3D(x, y, z, x1, y0, z1, seed); ix0 = Utils.linearInterp(n0, n1, xs); n0 = gradientNoise3D(x, y, z, x0, y1, z1, seed); n1 = gradientNoise3D(x, y, z, x1, y1, z1, seed); ix1 = Utils.linearInterp(n0, n1, xs); iy1 = Utils.linearInterp(ix0, ix1, ys); return Utils.linearInterp(iy0, iy1, zs);
int index0 = Utils.clamp(indexPos - 2, 0, lastIndex); int index1 = Utils.clamp(indexPos - 1, 0, lastIndex); int index2 = Utils.clamp(indexPos, 0, lastIndex); int index3 = Utils.clamp(indexPos + 1, 0, lastIndex); return Utils.cubicInterp(controlPoints.get(index0).outputValue, controlPoints.get(index1).outputValue, controlPoints.get(index2).outputValue, controlPoints.get(index3).outputValue, alpha);
int index0 = Utils.clamp(indexPos - 1, 0, controlPointCount - 1); int index1 = Utils.clamp(indexPos, 0, controlPointCount - 1); return Utils.linearInterp(value0, value1, alpha);
alpha = Utils.sCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve)); return Utils.linearInterp(sourceModule[0].getValue(x, y, z), sourceModule[1].getValue(x, y, z), alpha); } else if (controlValue < (upperBound - edgeFalloff)) { alpha = Utils.sCurve3((controlValue - lowerCurve) / (upperCurve - lowerCurve)); return Utils.linearInterp(sourceModule[1].getValue(x, y, z), sourceModule[0].getValue(x, y, z), alpha); } else {
@Override public double getValue(double x, double y, double z) { double z1 = z; double x1 = x; x1 *= frequency; z1 *= frequency; double distFromCenter = Math.sqrt(x1 * x1 + z1 * z1); double distFromSmallerSphere = distFromCenter - Utils.floor(distFromCenter); double distFromLargerSphere = 1.0 - distFromSmallerSphere; double nearestDist = Math.min(distFromSmallerSphere, distFromLargerSphere); return 1.0 - (nearestDist * 2.0); // Puts it in the 0 to 1 range. } }
nx = Utils.makeInt32Range(x1); ny = Utils.makeInt32Range(y1); nz = Utils.makeInt32Range(z1);
/** * Returns the output value from the noise module given the (latitude, longitude) coordinates of the specified input value located on the surface of the sphere. * * @param lat The latitude of the input value, in degrees. * @param lon The longitude of the input value, in degrees. * @return The output value from the noise module. */ public double getValue(double lat, double lon) { if (module == null) { throw new NoModuleException(); } double[] vec = Utils.latLonToXYZ(lat, lon); return module.getValue(vec[0], vec[1], vec[2]); } }
@Override public double getValue(double x, double y, double z) { if (sourceModule[0] == null) { throw new NoModuleException(); } if (sourceModule[1] == null) { throw new NoModuleException(); } if (sourceModule[2] == null) { throw new NoModuleException(); } double v0 = sourceModule[0].getValue(x, y, z); double v1 = sourceModule[1].getValue(x, y, z); double alpha = (sourceModule[2].getValue(x, y, z) + 1.0) / 2.0; return Utils.linearInterp(v0, v1, alpha); } }
zs = (z - (double) z0); } else if (quality == NoiseQuality.STANDARD) { xs = Utils.sCurve3(x - (double) x0); ys = Utils.sCurve3(y - (double) y0); zs = Utils.sCurve3(z - (double) z0); } else { xs = Utils.sCurve5(x - (double) x0); ys = Utils.sCurve5(y - (double) y0); zs = Utils.sCurve5(z - (double) z0); n0 = gradientNoise3D(x, y, z, x0, y0, z0, seed); n1 = gradientNoise3D(x, y, z, x1, y0, z0, seed); ix0 = Utils.linearInterp(n0, n1, xs); ix1 = Utils.linearInterp(n0, n1, xs); iy0 = Utils.linearInterp(ix0, ix1, ys); n0 = gradientNoise3D(x, y, z, x0, y0, z1, seed); n1 = gradientNoise3D(x, y, z, x1, y0, z1, seed); ix0 = Utils.linearInterp(n0, n1, xs); n0 = gradientNoise3D(x, y, z, x0, y1, z1, seed); n1 = gradientNoise3D(x, y, z, x1, y1, z1, seed); ix1 = Utils.linearInterp(n0, n1, xs); iy1 = Utils.linearInterp(ix0, ix1, ys); return Utils.linearInterp(iy0, iy1, zs);
@Override public double getValue(double x, double y, double z) { int ix = Utils.floor(Utils.makeInt32Range(x)); int iy = Utils.floor(Utils.makeInt32Range(y)); int iz = Utils.floor(Utils.makeInt32Range(z)); return ((ix & 1 ^ iy & 1 ^ iz & 1) != 0) ? 0 : 1.0; } }
int index0 = Utils.clamp(indexPos - 2, 0, controlPoints.size() - 1); int index1 = Utils.clamp(indexPos - 1, 0, controlPoints.size() - 1); int index2 = Utils.clamp(indexPos, 0, controlPoints.size() - 1); int index3 = Utils.clamp(indexPos + 1, 0, controlPoints.size() - 1); return Utils.cubicInterp(controlPoints.get(index0).outputValue, controlPoints.get(index1).outputValue, controlPoints.get(index2).outputValue, controlPoints.get(index3).outputValue, alpha);