00001
00002 #ifndef _SAMPLER_H
00003 #define _SAMPLER_H
00004
00005 #include <cstdlib>
00006 #include <time.h>
00007
00008 namespace gk {
00009
00010
00011 class Sampler
00012 {
00013 public:
00014 Sampler( ) {}
00015
00016 float uniformFloat( )
00017 {
00018 return (float) rand() / (float) RAND_MAX;
00019 }
00020
00021 int uniformInt( const int max )
00022 {
00023 return ((float) rand() * (float) max / (float) RAND_MAX) + .5f;
00024 }
00025
00026
00027 static void init( const int seed= 0 )
00028 {
00029 if(seed != 0)
00030 srand(seed);
00031 else
00032 srand(time(NULL));
00033 }
00034 };
00035
00036 }
00037
00038 #endif