static float grad(final int hash, final float x, final float y, final float z) {
        int h = hash & 15; // CONVERT LO 4 BITS OF HASH CODE
        float u = h < 8 ? x : y, // INTO 12 GRADIENT DIRECTIONS.
        v = h < 4 ? y : h == 12 || h == 14 ? x : z;
        return ((h & 1) == 0 ? u : -u) + ((h & 2) == 0 ? v : -v);
    }
Perlin's default implementation of Improved Perlin Noise
designed to work with Noise base
jme3-terrain/src/main/java/com/jme3/terrain/noise/basis/ImprovedNoise.java