Allolib
1.0
C++ Components For Interactive Multimedia
|
Public Member Functions | |
Random () | |
Default constructor uses a randomly generated seed. | |
Random (uint32_t seed) | |
Random & | seed (uint32_t v) |
Set seed. | |
RNG & | rng () |
Get underlying random number generator. | |
float | uniform () |
Returns uniform random in [0, 1) | |
template<class T > | |
T | uniform (const T &hi) |
Returns uniform random in [0, hi) | |
template<class T > | |
T | uniform (const T &hi, const T &lo) |
Returns uniform random in [lo, hi) | |
float | uniformS () |
Returns uniform random in [-1, 1) | |
template<class T > | |
T | uniformS (const T &lim) |
Returns uniform random in [-lim, lim) | |
template<int N, class T > | |
void | ball (T *point) |
Returns point within a unit ball. More... | |
template<template< int, class > class VecType, int N, class T > | |
void | ball (VecType< N, T > &point) |
Returns point within a unit ball. | |
template<class VecType > | |
VecType | ball () |
Returns point within a unit ball. | |
float | normal () |
Returns standard normal variate. | |
template<class T > | |
void | normal (T &y1, T &y2) |
Returns two standard normal variates (for the price of one) | |
float | triangle () |
Returns triangle distribution variate, in (-1,1) | |
template<class T > | |
T | triangle (const T &hi) |
Returns triangle distribution variate, in (-hi,hi) | |
float | sign (float x=1.f) |
Returns argument with sign randomly flipped. | |
bool | prob () |
Returns true with a probability of 0.5. | |
bool | prob (float p) |
Returns true with a probability of p. | |
template<class T > | |
void | shuffle (T *arr, uint32_t len) |
Randomly shuffles elements in array. | |
float | gaussian () |
template<class T > | |
void | gaussian (T &y1, T &y2) |
Protected Attributes | |
RNG | mRNG |
Random distribution generator
Definition at line 77 of file al_Random.hpp.
|
inline |
[in] | seed | Initial seed value |
Definition at line 83 of file al_Random.hpp.
Returns point within a unit ball.
To get a random point on a sphere, simply normalize the result.
N | dimensions of ball |
[in] | point | an array of size N |
Definition at line 355 of file al_Random.hpp.