Main Page   Namespace List   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields   Globals  

ExCRandomNumber Class Reference

#include <ExCRandomNumber.h>


Public Methods

 ExCRandomNumber ()
float getFloat (float, float)
uint getInt (uint, uint)

Static Private Attributes

int is_init = false


Constructor & Destructor Documentation

ExCRandomNumber  
 

Definition at line 28 of file ExCRandomNumber.cpp.

References is_init.

00028                                   {
00029         if (! is_init) {
00030                 srand (time (NULL));
00031                 is_init = true;
00032         }
00033 }


Member Function Documentation

float getFloat float   ,
float   
 

Definition at line 51 of file ExCRandomNumber.cpp.

References getInt().

Referenced by ExCSystemeParticule::Draw().

00051                                                      {
00052         float value;
00053         float v_tmp;
00054         if (max < min) {
00055                 v_tmp = min;
00056                 min = max;
00057                 max = v_tmp;
00058         }
00059 
00060         do {
00061                 value = min + (float) getInt(0, (unsigned) ((max - min) * 1000)) / 1000;
00062         } while (value < min || value > max);
00063         
00064         return value;
00065 }

uint getInt uint   ,
uint   
 

Definition at line 35 of file ExCRandomNumber.cpp.

References uint.

Referenced by ExCSystemeParticule::Draw(), and getFloat().

00035                                                 {
00036         uint value;
00037         uint v_tmp;
00038         if (max < min) {
00039                 v_tmp = min;
00040                 min = max;
00041                 max = v_tmp;
00042         }
00043         
00044         do {
00045                 value = (rand() % (max - min + 1)) + min;
00046         } while (value < min || value > max);
00047         
00048         return value;
00049 }


Field Documentation

int is_init = false [static, private]
 

Definition at line 26 of file ExCRandomNumber.cpp.

Referenced by ExCRandomNumber().


The documentation for this class was generated from the following files:
Generated on Tue Aug 6 20:27:22 2002 for ExNihilo by doxygen1.2.17