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
seeduintThe seed to initialize with.
Fields
state
The random number generator state. It should not be zero.
public uint state
Field Value
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
indexuintAn index that will be hashed for Random creation. Must not be uint.MaxValue.
Returns
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
seeduintThe 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
maxdoubleThe 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
mindoubleThe minimum value to generate, inclusive.
maxdoubleThe 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
maxdouble2The 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
mindouble2The componentwise minimum value to generate, inclusive.
maxdouble2The 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
maxdouble3The 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
mindouble3The componentwise minimum value to generate, inclusive.
maxdouble3The 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
maxdouble4The 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
mindouble4The componentwise minimum value to generate, inclusive.
maxdouble4The 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
maxfloatThe 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
minfloatThe minimum value to generate, inclusive.
maxfloatThe 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
maxfloat2The 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
minfloat2The componentwise minimum value to generate, inclusive.
maxfloat2The 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
maxfloat3The 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
minfloat3The componentwise minimum value to generate, inclusive.
maxfloat3The 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
maxfloat4The 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
minfloat4The componentwise minimum value to generate, inclusive.
maxfloat4The 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
maxintThe 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
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
maxint2The 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
minint2The componentwise minimum value to generate, inclusive.
maxint2The 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
maxint3The 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
minint3The componentwise minimum value to generate, inclusive.
maxint3The 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
maxint4The 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
minint4The componentwise minimum value to generate, inclusive.
maxint4The 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
maxuintThe 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
minuintThe minimum value to generate, inclusive.
maxuintThe 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
maxuint2The 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
minuint2The componentwise minimum value to generate, inclusive.
maxuint2The 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
maxuint3The 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
minuint3The componentwise minimum value to generate, inclusive.
maxuint3The 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
maxuint4The 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
minuint4The componentwise minimum value to generate, inclusive.
maxuint4The componentwise maximum value to generate, exclusive.
Returns
- uint4
A uniformly random uint4 in the range [min, max).