1 #ifndef REGULARSAMPLEGENERATOR_HXX
 2 #define REGULARSAMPLEGENERATOR_HXX
 3 
 4 #include "SampleGenerator.hxx"
 5 #include <math.h>
 6 
 7 class RegularSampleGenerator : public SampleGenerator 
 8 {
 9 public:
10 	virtual void GetSamples(int n,float *u, float *v, float *weight)
11 	{
12 		float stdweight = 1.0f / static_cast<float>(n),
13 		      mf        = sqrtf(static_cast<float>(n));
14 		int   m         = static_cast<int>(mf),
15 		      pos;
16 
17 		for (int i = 0; i < m; ++i)
18 			for (int j = 0; j < m; ++j)
19 			{
20 				pos = i * m + j;
21 				u[pos] = (static_cast<float>(i) + 0.5) / mf;
22 				v[pos] = (static_cast<float>(j) + 0.5) / mf;
23 				weight[pos] = stdweight;
24 			}
25 	};
26 
27 	virtual ~RegularSampleGenerator(){};
28 };
29 
30 #endif


syntax highlighted by Code2HTML, v. 0.9.1