Allolib  1.0
C++ Components For Interactive Multimedia
al::rnd Namespace Reference

Random number generation utilities. More...

Classes

class  Random
 
class  LinCon
 Linear congruential uniform pseudo-random number generator. More...
 
class  MulLinCon
 Multiplicative linear congruential uniform pseudo-random number generator. More...
 
class  Tausworthe
 Combined Tausworthe uniform pseudo-random number generator. More...
 

Functions

rand_uniformfglobal ()
 Get global random number generator.
 
rand_normalglobal_normal ()
 
rand_uniformiglobal_ui ()
 
int uniformi (int high)
 
int uniformi (int low, int high)
 
float uniform ()
 Returns uniform random in [0, 1)
 
template<class T >
uniform (const T &hi)
 Returns uniform random in [0, hi)
 
template<class T >
uniform (const T &hi, const T &lo)
 Returns uniform random in [lo, hi)
 
float uniformS ()
 Returns signed uniform random in (-1, 1)
 
template<class T >
float uniformS (const T &lim)
 Returns signed 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.
 
float gaussian ()
 
float triangle ()
 Returns triangle distribution variate, in (-1,1)
 
bool prob ()
 Returns true with probability 0.5.
 
bool prob (float p)
 Returns true with probability p.
 
float sign (float x=1.f)
 Returns argument with sign randomly flipped.
 

Detailed Description

Random number generation utilities.

Function Documentation

◆ ball()

template<int N, class T >
void al::rnd::ball ( T *  point)
inline

Returns point within a unit ball.

To get a random point on a sphere, simply normalize the result.

Template Parameters
Ndimensions of ball
Parameters
[in]pointan array of size N

Definition at line 148 of file al_StdRandom.hpp.