com.threerings.util
Class NoiseUtil

java.lang.Object
  extended by com.threerings.util.NoiseUtil

public class NoiseUtil
extends Object

Methods for generating Perlin noise. The algorithm used is that described in Ken Perlin's Improving Noise.


Field Summary
protected static int GRADIENT_MASK
          Mask for gradient values.
protected static int PERMUTATION_BITS
          The number of permutation bits.
protected static int PERMUTATION_COUNT
          The number of permutations stored.
protected static int PERMUTATION_MASK
          Mask for permutation table entries.
protected static int[] PERMUTATIONS
          Permutation table (doubled so that we can offset values without having to remask).
 
Constructor Summary
NoiseUtil()
           
 
Method Summary
protected static float ease(float t)
          Computes the ease parameter for the given linear value.
static float getNoise(float x)
          Returns the noise value at the specified coordinate.
static float getNoise(float x, float y)
          Returns the noise value at the specified coordinates.
static float getNoise(float x, float y, float z)
          Returns the noise value at the specified coordinates.
static float getNoise(float x, float y, int z)
          Returns the noise value at the specified coordinates.
static float getNoise(float x, int y)
          Returns the noise value at the specified coordinates.
protected static float grad(int hash, float x)
          Returns the dot product of the provided value with the hashed gradient.
protected static float grad(int hash, float x, float y)
          Returns the dot product of the provided values with the hashed gradient.
protected static float grad(int hash, float x, float y, float z)
          Returns the dot product of the provided values with the hashed gradient.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PERMUTATION_BITS

protected static final int PERMUTATION_BITS
The number of permutation bits.

See Also:
Constant Field Values

PERMUTATION_COUNT

protected static final int PERMUTATION_COUNT
The number of permutations stored.

See Also:
Constant Field Values

PERMUTATION_MASK

protected static final int PERMUTATION_MASK
Mask for permutation table entries.

See Also:
Constant Field Values

GRADIENT_MASK

protected static final int GRADIENT_MASK
Mask for gradient values.

See Also:
Constant Field Values

PERMUTATIONS

protected static final int[] PERMUTATIONS
Permutation table (doubled so that we can offset values without having to remask).

Constructor Detail

NoiseUtil

public NoiseUtil()
Method Detail

getNoise

public static float getNoise(float x)
Returns the noise value at the specified coordinate.


getNoise

public static float getNoise(float x,
                             int y)
Returns the noise value at the specified coordinates.


getNoise

public static float getNoise(float x,
                             float y)
Returns the noise value at the specified coordinates.


getNoise

public static float getNoise(float x,
                             float y,
                             int z)
Returns the noise value at the specified coordinates.


getNoise

public static float getNoise(float x,
                             float y,
                             float z)
Returns the noise value at the specified coordinates.


grad

protected static float grad(int hash,
                            float x)
Returns the dot product of the provided value with the hashed gradient.


grad

protected static float grad(int hash,
                            float x,
                            float y)
Returns the dot product of the provided values with the hashed gradient.


grad

protected static float grad(int hash,
                            float x,
                            float y,
                            float z)
Returns the dot product of the provided values with the hashed gradient.


ease

protected static float ease(float t)
Computes the ease parameter for the given linear value.