StratifiedSampleGenerator.h

Go to the documentation of this file.
00001 
00007 #ifndef STRATIFIEDSAMPLEGENERATOR_H
00008 #define STRATIFIEDSAMPLEGENERATOR_H STRATIFIEDSAMPLEGENERATOR_H
00009 
00010 #include "SampleGenerator.h"
00011 
00016 class StratifiedSampleGenerator : public SampleGenerator 
00017 {
00018 public:
00019 
00028     void GetSamples(int n, float* u, float* v, float* weight) const
00029     {    
00030         int m = (int)(sqrt((float)n));
00031         
00032         for (int i=0 ; i < m; i++)
00033         {
00034             for (int j=0; j < m; j++)
00035             {
00036                 u[i + j*m] = ((float)i+frand())/(float)m;
00037                 v[i + j*m] = ((float)j+frand())/(float)m;
00038                 weight[i + j*m] = 1.0 / float(n);
00039             }
00040         }
00041     };
00042 };
00043 
00044 #endif

Generated on Thu Jan 31 21:48:49 2008 for RayTracer by  doxygen 1.5.4