public static double GradientNoise3D( double fx, double fy, double fz, int ix, int iy, int iz, int seed) { VectorTable vectorTable = new VectorTable(); // Randomly generate a gradient vector given the integer coordinates of the // input value. This implementation generates a random number and uses it // as an index into a normalized-vector lookup table. int vectorIndex = (X_NOISE_GEN * ix + Y_NOISE_GEN * iy + Z_NOISE_GEN * iz + SEED_NOISE_GEN * seed) & 0xffffffff; vectorIndex ^= (vectorIndex >> SHIFT_NOISE_GEN); vectorIndex &= 0xff; double xvGradient = vectorTable.getRandomVectors(vectorIndex, 0); double yvGradient = vectorTable.getRandomVectors(vectorIndex, 1); double zvGradient = vectorTable.getRandomVectors(vectorIndex, 2); // array size too large when using this original, changed to above for all 3 // double zvGradient = vectorTable.getRandomVectors(vectorIndex << 2, 2); // Set up us another vector equal to the distance between the two vectors // passed to this function. double xvPoint = (fx - (double) ix); double yvPoint = (fy - (double) iy); double zvPoint = (fz - (double) iz); // Now compute the dot product of the gradient vector with the distance // vector. The resulting value is gradient noise. Apply a scaling value // so that this noise value ranges from -1.0 to 1.0. return ((xvGradient * xvPoint) + (yvGradient * yvPoint) + (zvGradient * zvPoint)) * 2.12; }