Package jme3utilities.math.noise
Class Generator
java.lang.Object
java.util.Random
jme3utilities.math.noise.Generator
- All Implemented Interfaces:
Serializable,RandomGenerator
Generate pseudo-random numbers, vectors, and selections.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface java.util.random.RandomGenerator
RandomGenerator.ArbitrarilyJumpableGenerator, RandomGenerator.JumpableGenerator, RandomGenerator.LeapableGenerator, RandomGenerator.SplittableGenerator, RandomGenerator.StreamableGenerator -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatnextFloat(float e1, float e2) Generate a single-precision value, uniformly distributed between 2 extremes.intnextInt(int e1, int e2) Generate an integer value, uniformly distributed between 2 extremes.intnextPoisson(double lambda) Generate an integer with a Poisson distribution, after Knuth.com.jme3.math.QuaternionGenerate a uniformly distributed, pseudo-random unit quaternion.com.jme3.math.QuaternionnextQuaternion(com.jme3.math.Quaternion storeResult) Generate a uniformly distributed, pseudo-random unit quaternion.com.jme3.math.Vector3fGenerate a uniformly distributed, pseudo-random unit vector.com.jme3.math.Vector3fnextUnitVector3f(com.jme3.math.Vector3f storeResult) Generate a uniformly distributed, pseudo-random unit vector.com.jme3.math.Vector3fGenerate a pseudo-random vector that is uniformly distributed throughout the unit sphere centered on the origin.com.jme3.math.Vector3fnextVector3f(com.jme3.math.Vector3f storeResult) Generate a pseudo-random vector that is uniformly distributed throughout the unit sphere centered on the origin.com.jme3.math.Vector3fortho(com.jme3.math.Vector3f input) Generate a pseudo-random unit vector orthogonal to the input vector.<E> Epick(E[] array) Pick a pseudo-random element from the specified array.intPick a pseudo-random bit with the specified value from the specified set.<E> EPick a pseudo-random element from the specified list.Methods inherited from class java.util.Random
doubles, doubles, doubles, doubles, ints, ints, ints, ints, longs, longs, longs, longs, next, nextBoolean, nextBytes, nextDouble, nextFloat, nextGaussian, nextInt, nextInt, nextLong, setSeedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.util.random.RandomGenerator
isDeprecated, nextDouble, nextDouble, nextExponential, nextFloat, nextGaussian, nextLong, nextLong
-
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 extremee2- 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 extremee2- 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
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
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
-