fCraft.MapGeneration.ImprovedNoise.Grad C# (CSharp) Method

Grad() static private method

static private Grad ( int hash, double x, double y, double z ) : double
hash int
x double
y double
z double
return double
        static double Grad( int hash, double x, double y, double z ) {
            int h = hash & 15; // CONVERT LOW 4 BITS OF HASH CODE
            double 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);
        }