Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. ## class RandomNumberGenerator
  2.  
  3. A minimal & cheap generator for pseudo-random numbers.
  4.  
  5. ### Constructors
  6.  
  7. These all set the seed to the specified parameters.
  8. ```cpp
  9. RandomNumberGenerator(unsigned int seed = unsigned(std::time(0))); // Derive the 64-Bit seed from a 32-Bit seed. If no seed is given use the system time as seed.
  10. RandomNumberGenerator(unsigned int lowSeed, unsigned int highSeed);
  11. RandomNumberGenerator(unsigned long long int fullSeed);
  12. ```
  13.  
  14. ### Generator Functions
  15.  
  16. Generate random numbers inside a specific range, this Range is always inclusive. (E.g. it is always possible that it returns the max value itself.)
  17. ```cpp
  18. float randFloat(); // float in [0.0, 1.0]
  19. float randFloat(float min, float max); // [min, max]
  20. float randFloat(float max); // [0, max]
  21. int randInt(int max);
  22. int randInt(int min, int max);
  23. ```
  24.  
  25. These functions generate a random number for every component of the vector and return them, again in a vector.
  26. ```cpp
  27. Vec2F randVec2F(){ return randVec2F(0.f, 1.f); };
  28. Vec3F randVec3F(){ return randVec3F(0.f, 1.f); };
  29. Vec2F randVec2F(Vec2F max){ return randVec2F(0.f, max); };
  30. Vec3F randVec3F(Vec3F max){ return randVec3F(0.f, max); };
  31. Vec2F randVec2F(Vec2F min, Vec2F max);
  32. Vec3F randVec3F(Vec3F min, Vec3F max);
  33. ```
  34.  
  35. Generates 32 random bits, all other generator functions are based on this one.
  36. ```cpp
  37. unsigned int generate();
  38. ```
  39.  
  40. ### Member Variables
  41.  
  42. ```cpp
  43. unsigned int HighSeed; // First 32 Bits of the Seed.
  44. unsigned int LowSeed; // Last 32 Bits of the Seed.
  45. ```
  46.  
  47. ### Global Variables
  48.  
  49. Outside of class scope
  50. ```cpp
  51. extern RandomNumberGenerator gRNG; // A global, default-initialized instance of the RandomNumberGenerator for convinience.
  52. ```
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement