class Random

Inherits: IScriptExportable

Generates pseudo random numbers using the Xorshift128 algorithm.

Suitable for high performance requirements.

Public

Constructors

Random

Random(uint32_t seed = 0)

Initializes a new generator using the specified seed.

Methods

SetSeed

void SetSeed(uint32_t seed)

Changes the seed of the generator to the specified value.

Get

uint32_t Get() const

Returns a random value in range [0, std::numeric_limits <uint32 _t>::max()].

GetRange

int32_t GetRange(int32_t min, int32_t max) const

Returns a random value in range [min, max].

GetUNorm

float GetUNorm() const

Returns a random value in range [0, 1].

GetSNorm

float GetSNorm() const

Returns a random value in range [-1, 1].

GetUnitVector

Vector3 GetUnitVector() const

Returns a random unit vector in three dimensions.

GetUnitVector2D

Vector2 GetUnitVector2D() const

Returns a random unit vector in two dimensions.

GetPointInSphere

Vector3 GetPointInSphere() const

Returns a random point inside a unit sphere.

GetPointInSphereShell

Vector3 GetPointInSphereShell(float thickness) const

Returns a random point inside the specified range in a sphere shell of unit radius, with the specified thickness, in range [0, 1].

Thickness of 0 will generate points on the sphere surface, while thickness of 1 will generate points within the entire sphere volume. Intermediate values represent the shell, which is a volume between two concentric spheres.

GetPointInCircle

Vector2 GetPointInCircle() const

Returns a random point inside a unit circle.

GetPointInCircleShell

Vector2 GetPointInCircleShell(float thickness) const

Returns a random point inside the specified range in a circle shell of unit radius, with the specified thickness, in range [0, 1].

Thickness of 0 will generate points on the circle edge, while thickness of 1 will generate points within the entire circle surface. Intermediate values represent the shell, which is the surface between two concentric circles.

GetPointInArc

Vector2 GetPointInArc(Degree angle) const

Returns a random point on a unit arc with the specified length (angle).

Angle of 360 represents a circle.

GetPointInArcShell

Vector2 GetPointInArcShell(Degree angle, float thickness) const

Returns a random point inside the specified range in an arc shell of unit radius, with the specified length (angle) and thickness in range [0, 1].

Angle of 360 represents a circle shell. Thickness of 0 will generate points on the arc edge, while thickness of 1 will generate points on the entire arc 'slice'. Intermediate vlaues represent the shell, which is the surface between two concentric circles.

GetBarycentric

Vector3 GetBarycentric() const

Returns a random set of Barycentric coordinates that may be used for generating random points on a triangle.

Private

Fields

mSeed

uint32_t[4] mSeed