Class Generator

java.lang.Object
java.util.Random
jme3utilities.math.noise.Generator
All Implemented Interfaces:
Serializable, RandomGenerator

public class Generator extends Random
Generate pseudo-random numbers, quaternions, vectors, and selections.
See Also:
  • Constructor Details

    • Generator

      public Generator()
      Instantiate a pseudo-random generator with a seed likely to be unique.
    • Generator

      public Generator(long seed)
      Instantiate a pseudo-random generator with the specified seed.
      Parameters:
      seed - initial value for the seed
  • Method Details

    • nextFloat

      public float nextFloat(float e1, float e2)
      Generate a single-precision value, uniformly distributed between 2 extremes.
      Parameters:
      e1 - the first extreme
      e2 - the 2nd extreme
      Returns:
      a pseudo-random value (≥min(e1,e2), ≤max(e1,e2))
    • nextInt

      public int nextInt(int e1, int e2)
      Generate an integer value, uniformly distributed between 2 extremes.
      Parameters:
      e1 - the first extreme
      e2 - the 2nd extreme
      Returns:
      a pseudo-random value (≥min(e1,e2), ≤max(e1,e2))
    • nextQuaternion

      public Quaternion nextQuaternion(Quaternion storeResult)
      Generate a uniformly distributed, pseudo-random unit quaternion.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a unit quaternion (either storeResult or a new instance)
    • nextUnitVector3f

      public Vector3f nextUnitVector3f(Vector3f storeResult)
      Generate a uniformly distributed, pseudo-random unit vector.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a unit vector (either storeResult or a new instance)
    • nextVector3f

      public Vector3f nextVector3f(Vector3f storeResult)
      Generate a pseudo-random vector that is uniformly distributed throughout the unit sphere centered on the origin.
      Parameters:
      storeResult - storage for the result (modified if not null)
      Returns:
      a vector with length≤1 (either storeResult or a new instance)
    • pick

      public <E> E pick(E[] array)
      Pick a pseudo-random element from the specified array.
      Type Parameters:
      E - the type of list elements
      Parameters:
      array - the array to select from (not null, may be empty)
      Returns:
      a pre-existing element of array, or null if it's empty