#include <random.h>
Public Member Functions | |
Random () | |
bool | GetBool () |
long | GetLong (long min, long max) |
double | GetDouble () |
double | GetDouble (double max) |
double | GetDouble (double min, double max) |
Point2i | GetPoint (const Rectanglei &rect) |
Point2i | GetPoint (const Point2i &pt) |
Definition at line 28 of file random.h.
Random::Random | ( | ) |
bool Random::GetBool | ( | ) |
double Random::GetDouble | ( | double | min, | |
double | max | |||
) |
Definition at line 56 of file random.cpp.
00056 { 00057 return min + GetDouble(max - min); 00058 }
Here is the call graph for this function:
double Random::GetDouble | ( | double | max | ) |
Definition at line 60 of file random.cpp.
00060 { 00061 return max * GetDouble(); 00062 }
Here is the call graph for this function:
double Random::GetDouble | ( | ) |
Get a random number between 0.0 and 1.0
Definition at line 69 of file random.cpp.
Here is the caller graph for this function:
long Random::GetLong | ( | long | min, | |
long | max | |||
) |
Génère un nombre entier aléatoire compris dans [min;max]
Definition at line 42 of file random.cpp.
00042 { 00043 return min + (long)GetDouble(max - min + 1); 00044 /* double r = rand(); 00045 00046 r *= (max - min); 00047 r /= RAND_MAX; 00048 if( r >= 0 ) 00049 r = floor(r + 0.5); 00050 else 00051 r = ceil(r - 0.5); 00052 00053 return min + (long)r; */ 00054 }
Here is the call graph for this function:
Here is the caller graph for this function:
Point2i Random::GetPoint | ( | const Rectanglei & | rect | ) |
Return a random point in the given rectangle.
rect | The rectangle in which the returned point will be. |
Definition at line 79 of file random.cpp.
00079 { 00080 Point2i topPoint = rect.GetPosition(); 00081 Point2i bottomPoint = rect.GetBottomRightPoint(); 00082 00083 return Point2i( GetLong(topPoint.x, bottomPoint.x), 00084 GetLong(topPoint.y, bottomPoint.y) ); 00085 }
Here is the call graph for this function: