7. Random generator library

The random library implements basic random routines.

All functions and symbols are in “random” module, use require to get access to it.

require random

7.1. Constants

LCG_RAND_MAX = 32767

maximum possible output of random number generator

LCG_RAND_MAX_BIG = 1073741823

maximum possible output of random_big_int

7.2. Seed and basic generators

random_seed(seed: int const)

random_seed returns int4

argument

argument type

seed

int const

constructs seed vector out of single integer seed

random_seed2D(seed: int4&; co: int2 const; cf: int const)

random_seed2D returns float4

argument

argument type

seed

int4&

co

int2 const

cf

int const

constructs seed vector out of 2d screen coordinates and frame counter cf

random_int(seed: int4&)

random_int returns int

argument

argument type

seed

int4&

random integer 0..32767 (LCG_RAND_MAX)

random_big_int(seed: int4&)

random_big_int returns int

argument

argument type

seed

int4&

random integer 0..32768*32768-1 (LCG_RAND_MAX_BIG)

random_int4(seed: int4&)

random_int4 returns int4

argument

argument type

seed

int4&

random int4, each component is 0..32767 (LCG_RAND_MAX)

random_float(seed: int4&)

random_float returns float

argument

argument type

seed

int4&

random float 0..1

random_float4(seed: int4&)

random_float4 returns float4

argument

argument type

seed

int4&

random float4, each component is 0..1

7.3. Specific distributions

random_unit_vector(seed: int4&)

random_unit_vector returns float3

argument

argument type

seed

int4&

random float3 unit vector (length=1.)

random_in_unit_sphere(seed: int4&)

random_in_unit_sphere returns float3

argument

argument type

seed

int4&

random float3 unit vector (length=1) which happens to be inside a sphere R=1

random_in_unit_disk(seed: int4&)

random_in_unit_disk returns float3

argument

argument type

seed

int4&

random float3 unit vector (length=1) which happens to be inside a disk R=1, Z=0