SimGear - Simulator Construction Tools
sg_random.h File Reference

Go to the source code of this file.

Classes

struct  mt
 

Macros

#define MT_M   397
 
#define MT_N   624
 

Functions

void mt_init (mt *mt, unsigned int seed)
 
void mt_init_time_10 (mt *mt)
 
double mt_rand (mt *mt)
 
unsigned int mt_rand32 (mt *mt)
 
double sg_random ()
 
void sg_srandom (unsigned int seed)
 
void sg_srandom_time ()
 
void sg_srandom_time_10 ()
 

Detailed Description

Routines to handle random number generation and hide platform differences.

Definition in file sg_random.h.

Macro Definition Documentation

#define MT_M   397

Definition at line 37 of file sg_random.h.

Referenced by mt_rand32().

#define MT_N   624

Definition at line 36 of file sg_random.h.

Referenced by mt_init(), and mt_rand32().

Function Documentation

void mt_init_time_10 ( mt mt)

Initialize a new MT state with a seed that only changes every 10 minutes. Used to synchronize multi-process deployments.

Definition at line 62 of file sg_random.c.

Referenced by SGSky::SGSky().

unsigned int mt_rand32 ( mt mt)

Generate a new 32-bit random number based on the given MT state.

Definition at line 67 of file sg_random.c.

Referenced by mt_rand().

void sg_srandom ( unsigned int  seed)

Seed the random number generater with your own seed so can set up repeatable randomization.

Parameters
seedrandom number generator seed

Definition at line 106 of file sg_random.c.

Referenced by SGLightFactory::getGuard(), SGLightFactory::getHoldShort(), SGLightFactory::getOdal(), SGLightFactory::getSequenced(), and main().

void sg_srandom_time ( )

Seed the random number generater with time() so we don't see the same sequence every time.

Definition at line 93 of file sg_random.c.

void sg_srandom_time_10 ( )

Seed the random number generater with time() in 10 minute intervals so we get the same sequence within 10 minutes interval. This is useful for synchronizing two display systems.

Definition at line 100 of file sg_random.c.

Referenced by SGCloudLayer::SGCloudLayer().