KS.Reactor.ksRandom Class Reference

Extends the built-in C# Random class with methods for generating floats, vectors, and quaternions. More...

Inheritance diagram for KS.Reactor.ksRandom:

Public Member Functions

 ksRandom ()
 Constructor. Initializes the seed to the microsecond timestamp. More...
 
 ksRandom (int seed)
 Constructor. More...
 
float NextFloat ()
 Random value between 0 (inclusive) and 1 (exclusive). More...
 
float NextFloat (float min, float max)
 Returns a random float within a range. More...
 
ksVector2 NextUnitVector2 ()
 Random vector2 with magnitude 1. More...
 
ksVector2 NextVector2 ()
 Random vector3 with magnitude less than 1. More...
 
ksVector2 NextVector2 (float minMagnitude, float maxMagnitude)
 Returns a random vector2 with magnitude within a range. More...
 
ksVector3 NextUnitVector3 ()
 Random vector3 with magnitude 1. More...
 
ksVector3 NextVector3 ()
 Random vector3 with magnitude less than 1. More...
 
ksVector3 NextVector3 (float minMagnitude, float maxMagnitude)
 Returns a random vector3 with magnitude within a range. More...
 
ksQuaternion NextQuaternion ()
 Random quaternion. More...
 

Properties

int Seed [get]
 Initial seed. More...
 

Detailed Description

Extends the built-in C# Random class with methods for generating floats, vectors, and quaternions.

Constructor & Destructor Documentation

◆ ksRandom() [1/2]

KS.Reactor.ksRandom.ksRandom ( )

Constructor. Initializes the seed to the microsecond timestamp.

◆ ksRandom() [2/2]

KS.Reactor.ksRandom.ksRandom ( int  seed)

Constructor.

Parameters
seedSeed for pseudo-random sequence.

Member Function Documentation

◆ NextFloat() [1/2]

float KS.Reactor.ksRandom.NextFloat ( )

Random value between 0 (inclusive) and 1 (exclusive).

Returns

◆ NextFloat() [2/2]

float KS.Reactor.ksRandom.NextFloat ( float  min,
float  max 
)

Returns a random float within a range.

Parameters
minMin value (inclusive).
maxMax value (exclusive)
Returns
Random number in the range.

◆ NextQuaternion()

ksQuaternion KS.Reactor.ksRandom.NextQuaternion ( )

Random quaternion.

Returns

◆ NextUnitVector2()

ksVector2 KS.Reactor.ksRandom.NextUnitVector2 ( )

Random vector2 with magnitude 1.

Returns

◆ NextUnitVector3()

ksVector3 KS.Reactor.ksRandom.NextUnitVector3 ( )

Random vector3 with magnitude 1.

Returns

◆ NextVector2() [1/2]

ksVector2 KS.Reactor.ksRandom.NextVector2 ( )

Random vector3 with magnitude less than 1.

Returns

◆ NextVector2() [2/2]

ksVector2 KS.Reactor.ksRandom.NextVector2 ( float  minMagnitude,
float  maxMagnitude 
)

Returns a random vector2 with magnitude within a range.

Parameters
minMagnitudeMin magnitude (inclusive).
maxMagnitudeMax magnitude (exclusive).
Returns
Random vector2 with magnitude within the range.

◆ NextVector3() [1/2]

ksVector3 KS.Reactor.ksRandom.NextVector3 ( )

Random vector3 with magnitude less than 1.

Returns

◆ NextVector3() [2/2]

ksVector3 KS.Reactor.ksRandom.NextVector3 ( float  minMagnitude,
float  maxMagnitude 
)

Returns a random vector3 with magnitude within a range.

Parameters
minMagnitudeMin magnitude(inclusive).
maxMagnitudeMax magnitude(exclusive).
Returns

Property Documentation

◆ Seed

int KS.Reactor.ksRandom.Seed
get

Initial seed.