Allolib  1.0
C++ Components For Interactive Multimedia
al::rnd::Random< RNG > Class Template Reference

#include <C:/Users/Andres/source/repos/casm_viewer/external/tinc/external/allolib/include/al/math/al_Random.hpp>

Public Member Functions

 Random ()
 Default constructor uses a randomly generated seed.
 
 Random (uint32_t seed)
 
Randomseed (uint32_t v)
 Set seed.
 
RNG & rng ()
 Get underlying random number generator.
 
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 uniform random in [-1, 1)
 
template<class 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 >
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
 

Detailed Description

template<class RNG = al::rnd::Tausworthe>
class al::rnd::Random< RNG >

Random distribution generator

Definition at line 77 of file al_Random.hpp.

Constructor & Destructor Documentation

◆ Random()

template<class RNG = al::rnd::Tausworthe>
al::rnd::Random< RNG >::Random ( uint32_t  seed)
inline
Parameters
[in]seedInitial seed value

Definition at line 83 of file al_Random.hpp.

Member Function Documentation

◆ ball()

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

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 355 of file al_Random.hpp.


The documentation for this class was generated from the following file: