src/main/java/com/flowpowered/noise/Noise.java
public static double gradientCoherentNoise3D(double x, double y, double z, int seed, NoiseQuality quality) {

        // Create a unit-length cube aligned along an integer boundary.  This cube
        // surrounds the input point.

        int x0 = ((x > 0.0) ? (int) x : (int) x - 1);
        int x1 = x0 + 1;

        int y0 = ((y > 0.0) ? (int) y : (int) y - 1);
        int y1 = y0 + 1;

        int z0 = ((z > 0.0) ? (int) z : (int) z - 1);
        int z1 = z0 + 1;

        // Map the difference between the coordinates of the input value and the
        // coordinates of the cube's outer-lower-left vertex onto an S-curve.
        double xs, ys, zs;
        if (quality == NoiseQuality.FAST) {
            xs = (x - (double) x0);
            ys = (y - (double) y0);
            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);
        }

        // Now calculate the noise values at each vertex of the cube.  To generate
        // the coherent-noise value at the input point, interpolate these eight
        // noise values using the S-curve value as the interpolant (trilinear
        // interpolation.)
        double n0, n1, ix0, ix1, iy0, iy1;
        n0 = gradientNoise3D(x, y, z, x0, y0, z0, seed);
        n1 = gradientNoise3D(x, y, z, x1, y0, z0, seed);
        ix0 = Utils.linearInterp(n0, n1, xs);

        n0 = gradientNoise3D(x, y, z, x0, y1, z0, seed);
        n1 = gradientNoise3D(x, y, z, x1, y1, z0, seed);
        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);
    }
public static double gradientCoherentNoise3D(double x, double y, double z, int seed, NoiseQuality quality) {

        // Create a unit-length cube aligned along an integer boundary.  This cube
        // surrounds the input point.

        int x0 = ((x > 0.0) ? (int) x : (int) x - 1);
        int x1 = x0 + 1;

        int y0 = ((y > 0.0) ? (int) y : (int) y - 1);
        int y1 = y0 + 1;

        int z0 = ((z > 0.0) ? (int) z : (int) z - 1);
        int z1 = z0 + 1;

        // Map the difference between the coordinates of the input value and the
        // coordinates of the cube's outer-lower-left vertex onto an S-curve.
        double xs, ys, zs;
        if (quality == NoiseQuality.FAST) {
            xs = (x - (double) x0);
            ys = (y - (double) y0);
            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);
        }

        // Now calculate the noise values at each vertex of the cube.  To generate
        // the coherent-noise value at the input point, interpolate these eight
        // noise values using the S-curve value as the interpolant (trilinear
        // interpolation.)
        double n0, n1, ix0, ix1, iy0, iy1;
        n0 = gradientNoise3D(x, y, z, x0, y0, z0, seed);
        n1 = gradientNoise3D(x, y, z, x1, y0, z0, seed);
        ix0 = Utils.linearInterp(n0, n1, xs);

        n0 = gradientNoise3D(x, y, z, x0, y1, z0, seed);
        n1 = gradientNoise3D(x, y, z, x1, y1, z0, seed);
        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);
    }
public static double gradientCoherentNoise3D ( double x , double y , double z , int seed , NoiseQuality quality ) { // Create a unit-length cube aligned along an integer boundary.  This cube // surrounds the input point. int x0 = ( ( x > 0.0 ) ? ( int ) x : ( int ) x - 1 ) ; int x1 = x0 + 1 ; int y0 = ( ( y > 0.0 ) ? ( int ) y : ( int ) y - 1 ) ; int y1 = y0 + 1 ; int z0 = ( ( z > 0.0 ) ? ( int ) z : ( int ) z - 1 ) ; int z1 = z0 + 1 ; // Map the difference between the coordinates of the input value and the // coordinates of the cube's outer-lower-left vertex onto an S-curve. double xs , ys , zs ; if ( quality == NoiseQuality . FAST ) { xs = ( x - ( double ) x0 ) ; ys = ( y - ( double ) y0 ) ; 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 ) ; } // Now calculate the noise values at each vertex of the cube.  To generate // the coherent-noise value at the input point, interpolate these eight // noise values using the S-curve value as the interpolant (trilinear // interpolation.) double n0 , n1 , ix0 , ix1 , iy0 , iy1 ; n0 = gradientNoise3D ( x , y , z , x0 , y0 , z0 , seed ) ; n1 = gradientNoise3D ( x , y , z , x1 , y0 , z0 , seed ) ; ix0 = Utils . linearInterp ( n0 , n1 , xs ) ; n0 = gradientNoise3D ( x , y , z , x0 , y1 , z0 , seed ) ; n1 = gradientNoise3D ( x , y , z , x1 , y1 , z0 , seed ) ; 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 ) ; }
Generates a gradient-coherent-noise value from the coordinates of a three-dimensional input value.

@param x The @a x coordinate of the input value.
@param y The @a y coordinate of the input value.
@param z The @a z coordinate of the input value.
@param seed The random number seed.
@param quality The quality of the coherent-noise.
@return The generated gradient-coherent-noise value.
<p/>
The return value ranges from 0 to 1.
<p/>
For an explanation of the difference between <i>gradient</i> noise and <i>value</i> noise, see the comments for the GradientNoise3D() function.
Generates a gradient - coherent - noise value from the coordinates of a three - dimensional input value .