Class GorgonRandom
A random number generator for floating point and integer values.
Inherited Members
Namespace: Gorgon.Core
Assembly: Gorgon.Core.dll
Syntax
public static class GorgonRandom
Remarks
This class expands upon the functionality of the Random class by providing float random numbers, and ranges for double and float random numbers.
It also provides a simplex noise implementation for generation of repeatable random noise.
The simplex noise functionality uses the Noise.cs functionality built by Benjamin Ward, which was based on another implementation by Heikki Törmälä. Both of which are derived from the original Java implementation by Stefan Gustavson.
- Benjamin Wardhttps://github.com/WardBenjamin/SimplexNoise
- Heikki Törmälähttps://github.com/Xpktro/simplexnoise/blob/master/SimplexNoise/Noise.cs
- Stefan Gustavsonhttp://staffwww.itn.liu.se/~stegu/aqsis/aqsis-newnoise/
Properties
| Edit this page View SourceSeed
Property to set or return the random seed value.
Declaration
public static int Seed { get; set; }
Property Value
Type | Description |
---|---|
int |
See Also
| Edit this page View SourceSimplexPermutations
Property to set or return the Simplex noise permutation array.
Declaration
public static IReadOnlyList<byte> SimplexPermutations { get; set; }
Property Value
Type | Description |
---|---|
IReadOnlyList<byte> |
Remarks
This is used to modify the random values generated by the Simplex noise algorithm.
See Also
Methods
| Edit this page View SourceRandomDouble()
Function to return a random double number.
Declaration
public static double RandomDouble()
Returns
Type | Description |
---|---|
double | A random double value between 0.0 and 1.0. |
See Also
| Edit this page View SourceRandomDouble(double)
Function to return a random double number.
Declaration
public static double RandomDouble(double maxValue)
Parameters
Type | Name | Description |
---|---|---|
double | maxValue | The highest number for random values, this value is inclusive. |
Returns
Type | Description |
---|---|
double | A random double value. |
Remarks
This overload generates a random double number between the range of 0 and maxValue
.
See Also
| Edit this page View SourceRandomDouble(double, double)
Function to return a random double number.
Declaration
public static double RandomDouble(double start, double end)
Parameters
Type | Name | Description |
---|---|---|
double | start | The starting value for the random number. |
double | end | The ending value for the random number range. This value is inclusive. |
Returns
Type | Description |
---|---|
double | A random double value between |
Remarks
This overload generates a random double number between the range of start
and end
.
See Also
| Edit this page View SourceRandomInt32()
Function to return a non-negative random int.
Declaration
public static int RandomInt32()
Returns
Type | Description |
---|---|
int |
See Also
| Edit this page View SourceRandomInt32(int)
Function to return a non-negative random int.
Declaration
public static int RandomInt32(int maxValue)
Parameters
Type | Name | Description |
---|---|---|
int | maxValue | The highest number for random values, this value is inclusive. |
Returns
Type | Description |
---|---|
int | A random number |
Remarks
This overload generates a random int number between the range of 0 and maxValue
-1.
See Also
| Edit this page View SourceRandomInt32(int, int)
Function to return a non-negative random int.
Declaration
public static int RandomInt32(int start, int end)
Parameters
Type | Name | Description |
---|---|---|
int | start | Starting value for the random number. |
int | end | Ending value for the random number range. This value is inclusive. |
Returns
Type | Description |
---|---|
int | The random int value within the range of |
Remarks
This overload generates a random int number between the range of start
and end
(inclusive).
See Also
| Edit this page View SourceRandomSingle()
Function to return a random float number.
Declaration
public static float RandomSingle()
Returns
Type | Description |
---|---|
float | A random float value between 0.0f and 1.0f. |
See Also
| Edit this page View SourceRandomSingle(float)
Function to return a random float number.
Declaration
public static float RandomSingle(float maxValue)
Parameters
Type | Name | Description |
---|---|---|
float | maxValue | The highest number for random values, this value is inclusive. |
Returns
Type | Description |
---|---|
float | A random float value. |
Remarks
This overload generates a random float number between the range of 0 and maxValue
.
See Also
| Edit this page View SourceRandomSingle(float, float)
Function to return a random float number.
Declaration
public static float RandomSingle(float start, float end)
Parameters
Type | Name | Description |
---|---|---|
float | start | The starting value for the random number. |
float | end | The ending value for the random number range. This value is inclusive. |
Returns
Type | Description |
---|---|
float | A random float value between |
Remarks
This overload generates a random float number between the range of start
and end
.
See Also
| Edit this page View SourceSimplexNoise(float)
Function to generate 1 dimensional simplex noise.
Declaration
public static float SimplexNoise(float value)
Parameters
Type | Name | Description |
---|---|---|
float | value | The float value to use to generate the simplex noise value. |
Returns
Type | Description |
---|---|
float | A float representing the simplex noise value. |
Remarks
Simplex noise values similar to Perlin noise but with fewer artifacts and better performance.
This produces predictable random numbers based on the seed value
passed to the method.
See Also
| Edit this page View SourceSimplexNoise(float, float)
Function to generate 2 dimensional simplex noise.
Declaration
public static float SimplexNoise(float x, float y)
Parameters
Type | Name | Description |
---|---|---|
float | x | The horizontal value to use to generate the simplex noise value. |
float | y | The vertical value to use to generate the simplex noise value. |
Returns
Type | Description |
---|---|
float | A float representing the simplex noise value. |
Remarks
Simplex noise values similar to Perlin noise but with fewer artifacts and better performance.
This produces predictable random numbers based on the seed value passed to the method.
See Also
| Edit this page View SourceSimplexNoise(float, float, float)
Function to generate 3 dimensional simplex noise.
Declaration
public static float SimplexNoise(float x, float y, float z)
Parameters
Type | Name | Description |
---|---|---|
float | x | The horizontal value to use to generate the simplex noise value. |
float | y | The vertical value to use to generate the simplex noise value. |
float | z | The depth value to use to generate the simplex noise value. |
Returns
Type | Description |
---|---|
float | A float representing the simplex noise value. |
Remarks
Simplex noise values similar to Perlin noise but with fewer artifacts and better performance.
This produces predictable random numbers based on the seed values passed to the method.