Panda3D
Public Member Functions | Static Public Member Functions | List of all members
Randomizer Class Reference

A handy class to return random numbers. More...

#include "randomizer.h"

Public Member Functions

 Randomizer (unsigned long seed=0)
 If seed is nonzero, it is used to define the tables; if it is zero a random seed is generated. More...
 
 Randomizer (const Randomizer &copy)
 
unsigned long get_seed ()
 Returns a unique seed value based on the seed value passed to this Randomizer object (and on its current state). More...
 
void operator= (const Randomizer &copy)
 
int random_int (int range)
 Returns a random integer in the range [0, range). More...
 
double random_real (double range)
 Returns a random double in the range [0, range). More...
 
double random_real_unit ()
 Returns a random double in the range [-0.5, 0.5). More...
 

Static Public Member Functions

static unsigned long get_next_seed ()
 Returns a random seed value for the next global Randomizer object. More...
 

Detailed Description

A handy class to return random numbers.

Definition at line 26 of file randomizer.h.

Constructor & Destructor Documentation

◆ Randomizer()

Randomizer::Randomizer ( unsigned long  seed = 0)
inlineexplicit

If seed is nonzero, it is used to define the tables; if it is zero a random seed is generated.

Definition at line 19 of file randomizer.I.

Member Function Documentation

◆ get_next_seed()

unsigned long Randomizer::get_next_seed ( )
inlinestatic

Returns a random seed value for the next global Randomizer object.

Definition at line 69 of file randomizer.I.

◆ get_seed()

unsigned long Randomizer::get_seed ( )
inline

Returns a unique seed value based on the seed value passed to this Randomizer object (and on its current state).

Definition at line 82 of file randomizer.I.

Referenced by PerlinNoise::get_seed().

◆ random_int()

int Randomizer::random_int ( int  range)
inline

Returns a random integer in the range [0, range).

Definition at line 45 of file randomizer.I.

References random_real().

◆ random_real()

double Randomizer::random_real ( double  range)
inline

Returns a random double in the range [0, range).

Definition at line 53 of file randomizer.I.

Referenced by random_int(), and random_real_unit().

◆ random_real_unit()

double Randomizer::random_real_unit ( )
inline

Returns a random double in the range [-0.5, 0.5).

Definition at line 61 of file randomizer.I.

References random_real().


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