Gorgon
Show / Hide Table of Contents

Class GorgonRandom

A random number generator for floating point and integer values.

Inheritance
object
GorgonRandom
Inherited Members
object.ToString()
object.Equals(object)
object.Equals(object, object)
object.ReferenceEquals(object, object)
object.GetHashCode()
object.GetType()
object.MemberwiseClone()
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 Source

Seed

Property to set or return the random seed value.

Declaration
public static int Seed { get; set; }
Property Value
Type Description
int
See Also
Random
| Edit this page View Source

SimplexPermutations

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
Random

Methods

| Edit this page View Source

RandomDouble()

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
Random
| Edit this page View Source

RandomDouble(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
Random
| Edit this page View Source

RandomDouble(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 start to end.

Remarks

This overload generates a random double number between the range of start and end.

See Also
Random
| Edit this page View Source

RandomInt32()

Function to return a non-negative random int.

Declaration
public static int RandomInt32()
Returns
Type Description
int

A random int value between 0 and MaxValue-1.

See Also
Random
| Edit this page View Source

RandomInt32(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
Random
| Edit this page View Source

RandomInt32(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 start to end (inclusive).

Remarks

This overload generates a random int number between the range of start and end (inclusive).

See Also
Random
| Edit this page View Source

RandomSingle()

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
Random
| Edit this page View Source

RandomSingle(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
Random
| Edit this page View Source

RandomSingle(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 start to end.

Remarks

This overload generates a random float number between the range of start and end.

See Also
Random
| Edit this page View Source

SimplexNoise(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
Random
| Edit this page View Source

SimplexNoise(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
Random
| Edit this page View Source

SimplexNoise(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.

See Also
Random

See Also

Random
  • Edit this page
  • View Source
In this article
Back to top Copyright 2023 - Licensed under the MIT license by Michael Winsor (Tape_Worm).
Send comments on this topic to the author