Table of Contents

Struct random

Namespace
Misaki.HighPerformance.Mathematics
Assembly
Misaki.HighPerformance.Mathematics.dll
public struct random
Inherited Members

Constructors

random(uint)

Constructs a Random instance with a given seed value. The seed must be non-zero.

public random(uint seed)

Parameters

seed uint

The seed to initialize with.

Fields

state

The random number generator state. It should not be zero.

public uint state

Field Value

uint

Methods

CreateFromIndex(uint)

Constructs a random instance with an index that gets hashed. The index must not be uint.MaxValue.

public static random CreateFromIndex(uint index)

Parameters

index uint

An index that will be hashed for Random creation. Must not be uint.MaxValue.

Returns

random

random created from an index.

Examples

for (uint i = 0; i < 4096; ++i)
{
    Random rand = Random.CreateFromIndex(i);

    // Random numbers drawn from loop iteration j will be very different
    // from every other loop iteration k.
    rand.NextUInt();
}

Remarks

Use this function when you expect to create several Random instances in a loop.

InitState(uint)

Initialized the state of the Random instance with a given seed value. The seed must be non-zero.

public void InitState(uint seed = 1851936439)

Parameters

seed uint

The seed to initialize with.

NextBool()

Returns a uniformly random bool value.

public bool NextBool()

Returns

bool

A uniformly random boolean value.

NextBool2()

Returns a uniformly random bool2 value.

public bool2 NextBool2()

Returns

bool2

A uniformly random bool2 value.

NextBool3()

Returns a uniformly random bool3 value.

public bool3 NextBool3()

Returns

bool3

A uniformly random bool3 value.

NextBool4()

Returns a uniformly random bool4 value.

public bool4 NextBool4()

Returns

bool4

A uniformly random bool4 value.

NextDouble()

Returns a uniformly random double value in the interval [0, 1).

public double NextDouble()

Returns

double

A uniformly random double value in the range [0, 1).

NextDouble(double)

Returns a uniformly random double value in the interval [0, max).

public double NextDouble(double max)

Parameters

max double

The maximum value to generate, exclusive.

Returns

double

A uniformly random double value in the range [0, max).

NextDouble(double, double)

Returns a uniformly random double value in the interval [min, max).

public double NextDouble(double min, double max)

Parameters

min double

The minimum value to generate, inclusive.

max double

The maximum value to generate, exclusive.

Returns

double

A uniformly random double value in the range [min, max).

NextDouble2()

Returns a uniformly random double2 value with all components in the interval [0, 1).

public double2 NextDouble2()

Returns

double2

A uniformly random double2 value in the range [0, 1).

NextDouble2(double2)

Returns a uniformly random double2 value with all components in the interval [0, max).

public double2 NextDouble2(double2 max)

Parameters

max double2

The componentwise maximum value to generate, exclusive.

Returns

double2

A uniformly random double2 value in the range [0, max).

NextDouble2(double2, double2)

Returns a uniformly random double2 value with all components in the interval [min, max).

public double2 NextDouble2(double2 min, double2 max)

Parameters

min double2

The componentwise minimum value to generate, inclusive.

max double2

The componentwise maximum value to generate, exclusive.

Returns

double2

A uniformly random double2 value in the range [min, max).

NextDouble2Direction()

Returns a unit length double2 vector representing a uniformly random 2D direction.

public double2 NextDouble2Direction()

Returns

double2

A uniformly random unit length double2 vector.

NextDouble3()

Returns a uniformly random double3 value with all components in the interval [0, 1).

public double3 NextDouble3()

Returns

double3

A uniformly random double3 value in the range [0, 1).

NextDouble3(double3)

Returns a uniformly random double3 value with all components in the interval [0, max).

public double3 NextDouble3(double3 max)

Parameters

max double3

The componentwise maximum value to generate, exclusive.

Returns

double3

A uniformly random double3 value in the range [0, max).

NextDouble3(double3, double3)

Returns a uniformly random double3 value with all components in the interval [min, max).

public double3 NextDouble3(double3 min, double3 max)

Parameters

min double3

The componentwise minimum value to generate, inclusive.

max double3

The componentwise maximum value to generate, exclusive.

Returns

double3

A uniformly random double3 value in the range [min, max).

NextDouble3Direction()

Returns a unit length double3 vector representing a uniformly random 3D direction.

public double3 NextDouble3Direction()

Returns

double3

A uniformly random unit length double3 vector.

NextDouble4()

Returns a uniformly random double4 value with all components in the interval [0, 1).

public double4 NextDouble4()

Returns

double4

A uniformly random double4 value in the range [0, 1).

NextDouble4(double4)

Returns a uniformly random double4 value with all components in the interval [0, max).

public double4 NextDouble4(double4 max)

Parameters

max double4

The componentwise maximum value to generate, exclusive.

Returns

double4

A uniformly random double4 value in the range [0, max).

NextDouble4(double4, double4)

Returns a uniformly random double4 value with all components in the interval [min, max).

public double4 NextDouble4(double4 min, double4 max)

Parameters

min double4

The componentwise minimum value to generate, inclusive.

max double4

The componentwise maximum value to generate, exclusive.

Returns

double4

A uniformly random double4 value in the range [min, max).

NextFloat()

Returns a uniformly random float value in the interval [0, 1).

public float NextFloat()

Returns

float

A uniformly random float value in the range [0, 1).

NextFloat(float)

Returns a uniformly random float value in the interval [0, max).

public float NextFloat(float max)

Parameters

max float

The maximum value to generate, exclusive.

Returns

float

A uniformly random float value in the range [0, max).

NextFloat(float, float)

Returns a uniformly random float value in the interval [min, max).

public float NextFloat(float min, float max)

Parameters

min float

The minimum value to generate, inclusive.

max float

The maximum value to generate, exclusive.

Returns

float

A uniformly random float value in the range [min, max).

NextFloat2()

Returns a uniformly random float2 value with all components in the interval [0, 1).

public float2 NextFloat2()

Returns

float2

A uniformly random float2 value in the range [0, 1).

NextFloat2(float2)

Returns a uniformly random float2 value with all components in the interval [0, max).

public float2 NextFloat2(float2 max)

Parameters

max float2

The componentwise maximum value to generate, exclusive.

Returns

float2

A uniformly random float2 value in the range [0, max).

NextFloat2(float2, float2)

Returns a uniformly random float2 value with all components in the interval [min, max).

public float2 NextFloat2(float2 min, float2 max)

Parameters

min float2

The componentwise minimum value to generate, inclusive.

max float2

The componentwise maximum value to generate, exclusive.

Returns

float2

A uniformly random float2 value in the range [min, max).

NextFloat2Direction()

Returns a unit length float2 vector representing a uniformly random 2D direction.

public float2 NextFloat2Direction()

Returns

float2

A uniformly random unit length float2 vector.

NextFloat3()

Returns a uniformly random float3 value with all components in the interval [0, 1).

public float3 NextFloat3()

Returns

float3

A uniformly random float3 value in the range [0, 1).

NextFloat3(float3)

Returns a uniformly random float3 value with all components in the interval [0, max).

public float3 NextFloat3(float3 max)

Parameters

max float3

The componentwise maximum value to generate, exclusive.

Returns

float3

A uniformly random float3 value in the range [0, max).

NextFloat3(float3, float3)

Returns a uniformly random float3 value with all components in the interval [min, max).

public float3 NextFloat3(float3 min, float3 max)

Parameters

min float3

The componentwise minimum value to generate, inclusive.

max float3

The componentwise maximum value to generate, exclusive.

Returns

float3

A uniformly random float3 value in the range [min, max).

NextFloat3Direction()

Returns a unit length float3 vector representing a uniformly random 3D direction.

public float3 NextFloat3Direction()

Returns

float3

A uniformly random unit length float3 vector.

NextFloat4()

Returns a uniformly random float4 value with all components in the interval [0, 1).

public float4 NextFloat4()

Returns

float4

A uniformly random float4 value in the range [0, 1).

NextFloat4(float4)

Returns a uniformly random float4 value with all components in the interval [0, max).

public float4 NextFloat4(float4 max)

Parameters

max float4

The componentwise maximum value to generate, exclusive.

Returns

float4

A uniformly random float4 value in the range [0, max).

NextFloat4(float4, float4)

Returns a uniformly random float4 value with all components in the interval [min, max).

public float4 NextFloat4(float4 min, float4 max)

Parameters

min float4

The componentwise minimum value to generate, inclusive.

max float4

The componentwise maximum value to generate, exclusive.

Returns

float4

A uniformly random float4 value in the range [min, max).

NextInt()

Returns a uniformly random int value in the interval [-2147483647, 2147483647].

public int NextInt()

Returns

int

A uniformly random integer value.

NextInt(int)

Returns a uniformly random int value in the interval [0, max).

public int NextInt(int max)

Parameters

max int

The maximum value to generate, exclusive.

Returns

int

A uniformly random int value in the range [0, max).

NextInt(int, int)

Returns a uniformly random int value in the interval [min, max).

public int NextInt(int min, int max)

Parameters

min int

The minimum value to generate, inclusive.

max int

The maximum value to generate, exclusive.

Returns

int

A uniformly random integer between [min, max).

NextInt2()

Returns a uniformly random int2 value with all components in the interval [-2147483647, 2147483647].

public int2 NextInt2()

Returns

int2

A uniformly random int2 value.

NextInt2(int2)

Returns a uniformly random int2 value with all components in the interval [0, max).

public int2 NextInt2(int2 max)

Parameters

max int2

The componentwise maximum value to generate, exclusive.

Returns

int2

A uniformly random int2 value with all components in the range [0, max).

NextInt2(int2, int2)

Returns a uniformly random int2 value with all components in the interval [min, max).

public int2 NextInt2(int2 min, int2 max)

Parameters

min int2

The componentwise minimum value to generate, inclusive.

max int2

The componentwise maximum value to generate, exclusive.

Returns

int2

A uniformly random int2 between [min, max).

NextInt3()

Returns a uniformly random int3 value with all components in the interval [-2147483647, 2147483647].

public int3 NextInt3()

Returns

int3

A uniformly random int3 value.

NextInt3(int3)

Returns a uniformly random int3 value with all components in the interval [0, max).

public int3 NextInt3(int3 max)

Parameters

max int3

The componentwise maximum value to generate, exclusive.

Returns

int3

A uniformly random int3 value with all components in the range [0, max).

NextInt3(int3, int3)

Returns a uniformly random int3 value with all components in the interval [min, max).

public int3 NextInt3(int3 min, int3 max)

Parameters

min int3

The componentwise minimum value to generate, inclusive.

max int3

The componentwise maximum value to generate, exclusive.

Returns

int3

A uniformly random int3 between [min, max).

NextInt4()

Returns a uniformly random int4 value with all components in the interval [-2147483647, 2147483647].

public int4 NextInt4()

Returns

int4

A uniformly random int4 value.

NextInt4(int4)

Returns a uniformly random int4 value with all components in the interval [0, max).

public int4 NextInt4(int4 max)

Parameters

max int4

The componentwise maximum value to generate, exclusive.

Returns

int4

A uniformly random int4 value with all components in the range [0, max).

NextInt4(int4, int4)

Returns a uniformly random int4 value with all components in the interval [min, max).

public int4 NextInt4(int4 min, int4 max)

Parameters

min int4

The componentwise minimum value to generate, inclusive.

max int4

The componentwise maximum value to generate, exclusive.

Returns

int4

A uniformly random int4 between [min, max).

NextQuaternionRotation()

Returns a unit length quaternion representing a uniformly 3D rotation.

public quaternion NextQuaternionRotation()

Returns

quaternion

A uniformly random unit length quaternion.

NextUInt()

Returns a uniformly random uint value in the interval [0, 4294967294].

public uint NextUInt()

Returns

uint

A uniformly random unsigned integer.

NextUInt(uint)

Returns a uniformly random uint value in the interval [0, max).

public uint NextUInt(uint max)

Parameters

max uint

The maximum value to generate, exclusive.

Returns

uint

A uniformly random unsigned integer in the range [0, max).

NextUInt(uint, uint)

Returns a uniformly random uint value in the interval [min, max).

public uint NextUInt(uint min, uint max)

Parameters

min uint

The minimum value to generate, inclusive.

max uint

The maximum value to generate, exclusive.

Returns

uint

A uniformly random unsigned integer in the range [min, max).

NextUInt2()

Returns a uniformly random uint2 value with all components in the interval [0, 4294967294].

public uint2 NextUInt2()

Returns

uint2

A uniformly random uint2.

NextUInt2(uint2)

Returns a uniformly random uint2 value with all components in the interval [0, max).

public uint2 NextUInt2(uint2 max)

Parameters

max uint2

The componentwise maximum value to generate, exclusive.

Returns

uint2

A uniformly random uint2 in the range [0, max).

NextUInt2(uint2, uint2)

Returns a uniformly random uint2 value with all components in the interval [min, max).

public uint2 NextUInt2(uint2 min, uint2 max)

Parameters

min uint2

The componentwise minimum value to generate, inclusive.

max uint2

The componentwise maximum value to generate, exclusive.

Returns

uint2

A uniformly random uint2 in the range [min, max).

NextUInt3()

Returns a uniformly random uint3 value with all components in the interval [0, 4294967294].

public uint3 NextUInt3()

Returns

uint3

A uniformly random uint3.

NextUInt3(uint3)

Returns a uniformly random uint3 value with all components in the interval [0, max).

public uint3 NextUInt3(uint3 max)

Parameters

max uint3

The componentwise maximum value to generate, exclusive.

Returns

uint3

A uniformly random uint3 in the range [0, max).

NextUInt3(uint3, uint3)

Returns a uniformly random uint3 value with all components in the interval [min, max).

public uint3 NextUInt3(uint3 min, uint3 max)

Parameters

min uint3

The componentwise minimum value to generate, inclusive.

max uint3

The componentwise maximum value to generate, exclusive.

Returns

uint3

A uniformly random uint3 in the range [min, max).

NextUInt4()

Returns a uniformly random uint4 value with all components in the interval [0, 4294967294].

public uint4 NextUInt4()

Returns

uint4

A uniformly random uint4.

NextUInt4(uint4)

Returns a uniformly random uint4 value with all components in the interval [0, max).

public uint4 NextUInt4(uint4 max)

Parameters

max uint4

The componentwise maximum value to generate, exclusive.

Returns

uint4

A uniformly random uint4 in the range [0, max).

NextUInt4(uint4, uint4)

Returns a uniformly random uint4 value with all components in the interval [min, max).

public uint4 NextUInt4(uint4 min, uint4 max)

Parameters

min uint4

The componentwise minimum value to generate, inclusive.

max uint4

The componentwise maximum value to generate, exclusive.

Returns

uint4

A uniformly random uint4 in the range [min, max).