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, 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))
    • nextPoisson

      public int nextPoisson(double lambda)
      Generate an integer with a Poisson distribution, after Knuth.
      Parameters:
      lambda - the expected rate of arrivals per unit time (>0)
      Returns:
      the number of arrivals observed in a unit time interval (≥0)
    • nextQuaternion

      public com.jme3.math.Quaternion nextQuaternion()
      Generate a uniformly distributed, pseudo-random unit quaternion.
      Returns:
      a new unit quaternion
    • nextQuaternion

      public com.jme3.math.Quaternion nextQuaternion(com.jme3.math.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 com.jme3.math.Vector3f nextUnitVector3f()
      Generate a uniformly distributed, pseudo-random unit vector.
      Returns:
      a new unit vector
    • nextUnitVector3f

      public com.jme3.math.Vector3f nextUnitVector3f(com.jme3.math.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 com.jme3.math.Vector3f nextVector3f()
      Generate a pseudo-random vector that is uniformly distributed throughout the unit sphere centered on the origin.
      Returns:
      a new vector with length≤1
    • nextVector3f

      public com.jme3.math.Vector3f nextVector3f(com.jme3.math.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)
    • ortho

      public com.jme3.math.Vector3f ortho(com.jme3.math.Vector3f input)
      Generate a pseudo-random unit vector orthogonal to the input vector.
      Parameters:
      input - direction vector (not null, not zero, unaffected)
      Returns:
      a new unit vector
    • 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
    • pick

      public int pick(BitSet bitset, int maxIndex, boolean bitValue)
      Pick a pseudo-random bit with the specified value from the specified set.
      Parameters:
      bitset - (not null, positive size, unaffected)
      maxIndex - the last usable bit index (≥0, <size)
      bitValue - true or false
      Returns:
      bit index (≥0, ≤maxIndex)
    • pick

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