java.lang.Object
org.openpatch.scratch.extensions.math.Random

public class Random extends Object
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 Type
    Method
    Description
    static double
    noise(double x)
     
    static double
    noise(double x, double y)
    Returns the Open Simplex noise value at specified coordinates
    static double
    noise(double x, double y, double z)
    Returns the Open Simplex noise value at specified coordinates
    static void
    noiseSeed(long noiseSeed)
    Sets the seed for the noise method.
    static double
    Returns a random double between 0 and 1.
    static double
    random(double max)
    Returns a random double between 0 and max.
    static double
    random(double min, double max)
    Returns a random double between min and max.
    static int
    randomInt(int max)
    Returns a random integer between 0 and max.
    static int
    randomInt(int min, int max)
    Returns a random integer between min and max.
    static Vector2
    Returns a random position with respect to the width of the window.
    static void
    randomSeed(long seed)
    Sets the seed for the random method.
    static Vector2
    Returns a random unit vector
    static double
    Return a random x coordinate with respect to the width of the window.
    static double
    Return a random y coordinate with respect to the width of the window.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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-coordinate
      y - 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-coordinate
      y - y-coordinate
      z - 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

      public static Vector2 randomVector2()
      Returns a random unit vector
      Returns:
      a random unit vector
    • 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

      public static Vector2 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 integer
      max - 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 double
      max - 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