Class Random
java.lang.Object
org.openpatch.scratch.extensions.math.Random
The Random class provides various methods for generating random values and noise. It includes
methods for generating Open Simplex noise, random vectors, random coordinates, and random numbers
within specified ranges.
Methods in this class are static and can be accessed directly without creating an instance of the class.
Example usage:
double noiseValue = Random.noise(10.0);
Vector2 randomVector = Random.randomVector2();
double randomX = Random.randomX();
double randomY = Random.randomY();
Vector2 randomPosition = Random.randomPosition();
double randomDouble = Random.random();
int randomInt = Random.randomInt(100);
double randomDoubleInRange = Random.random(5.0, 10.0);
Note: The noise methods use Open Simplex noise, and the random methods use java.util.Random.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublenoise(double x) static doublenoise(double x, double y) Returns the Open Simplex noise value at specified coordinatesstatic doublenoise(double x, double y, double z) Returns the Open Simplex noise value at specified coordinatesstatic voidnoiseSeed(long noiseSeed) Sets the seed for the noise method.static doublerandom()Returns a random double between 0 and 1.static doublerandom(double max) Returns a random double between 0 and max.static doublerandom(double min, double max) Returns a random double between min and max.static intrandomInt(int max) Returns a random integer between 0 and max.static intrandomInt(int min, int max) Returns a random integer between min and max.static Vector2Returns a random position with respect to the width of the window.static voidrandomSeed(long seed) Sets the seed for the random method.static Vector2Returns a random unit vectorstatic doublerandomX()Return a random x coordinate with respect to the width of the window.static doublerandomY()Return a random y coordinate with respect to the width of the window.
-
Method Details
-
noise
public static double noise(double x) -
noise
public static double noise(double x, double y) Returns the Open Simplex noise value at specified coordinates- Parameters:
x- x-coordinatey- y-coordinate- Returns:
- the noise value
-
noise
public static double noise(double x, double y, double z) Returns the Open Simplex noise value at specified coordinates- Parameters:
x- x-coordinatey- y-coordinatez- z-coordinate- Returns:
- the noise value
-
noiseSeed
public static void noiseSeed(long noiseSeed) Sets the seed for the noise method.- Parameters:
noiseSeed- the seed
-
randomVector2
-
randomX
public static double randomX()Return a random x coordinate with respect to the width of the window.- Returns:
- a random x coordinate
-
randomY
public static double randomY()Return a random y coordinate with respect to the width of the window.- Returns:
- a random y coordinate
-
randomPosition
Returns a random position with respect to the width of the window.- Returns:
- a random position vector
-
random
public static double random()Returns a random double between 0 and 1.- Returns:
- a random double
-
randomInt
public static int randomInt(int max) Returns a random integer between 0 and max.- Parameters:
max- the maximum integer- Returns:
- a random integer
-
random
public static double random(double max) Returns a random double between 0 and max.- Parameters:
max- the maximum double- Returns:
- a random double
-
randomInt
public static int randomInt(int min, int max) Returns a random integer between min and max.- Parameters:
min- the minimum integermax- the maximum integer- Returns:
- a random integer
-
random
public static double random(double min, double max) Returns a random double between min and max.- Parameters:
min- the minimum doublemax- the maximum double- Returns:
- a random double
-
randomSeed
public static void randomSeed(long seed) Sets the seed for the random method.- Parameters:
seed- the seed
-