In Ken Perlin's improvement on his own Perlin Noise formula he has a certain grad function where he calculates the pseudorandom gradient
can anyone tell me what the syntax he's using actually means? I'm not familiar with it. This is the grad function he wrote:
static double grad(int hash, double x, double y, double z)
{
int h = hash & 15; // CONVERT LO 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);
}