fCraft.PerlinNoise3D.Grad C# (CSharp) Method

Grad() private static method

private static Grad ( int hashCode, float x, float y, float z ) : float
hashCode int
x float
y float
z float
return float
        private static float Grad( int hashCode, float x, float y, float z )
        {
            // Convert lower 4 bits of hash code into 12 gradient directions
            int h = hashCode & 15;
            float u = h < 8 ? x : y;
            float v = h < 4 ? y : h == 12 || h == 14 ? x : z;
            return ( ( ( h & 1 ) == 0 ? u : -u ) + ( ( h & 2 ) == 0 ? v : -v ) );
        }