1 | #ifndef __SAMPLEGENERATOR_H
|
---|
2 | #define __SAMPLEGENERATOR_H
|
---|
3 |
|
---|
4 | #include "Halton.h"
|
---|
5 |
|
---|
6 |
|
---|
7 | /** Class that generates samples on a circle
|
---|
8 | */
|
---|
9 |
|
---|
10 | struct Sample2
|
---|
11 | {
|
---|
12 | Sample2() {}
|
---|
13 | Sample2(float _x, float _y): x(_x), y(_y) {}
|
---|
14 |
|
---|
15 | float x;
|
---|
16 | float y;
|
---|
17 | };
|
---|
18 |
|
---|
19 |
|
---|
20 | struct Sample3
|
---|
21 | {
|
---|
22 | Sample3() {}
|
---|
23 | Sample3(float _x, float _y, float _z): x(_x), y(_y), z(_z) {}
|
---|
24 |
|
---|
25 | float x;
|
---|
26 | float y;
|
---|
27 | float z;
|
---|
28 | };
|
---|
29 |
|
---|
30 | /** Class generating random samples on a disc or in a sphere, respectively.
|
---|
31 | */
|
---|
32 | class SampleGenerator
|
---|
33 | {
|
---|
34 | public:
|
---|
35 |
|
---|
36 | SampleGenerator(int numSamples, float radius);
|
---|
37 |
|
---|
38 | virtual void Generate(float *samples) const = 0;
|
---|
39 |
|
---|
40 | protected:
|
---|
41 |
|
---|
42 | SampleGenerator() {};
|
---|
43 |
|
---|
44 | int mNumSamples;
|
---|
45 | float mRadius;
|
---|
46 | };
|
---|
47 |
|
---|
48 |
|
---|
49 | class PseudoRandomGenerator: public SampleGenerator
|
---|
50 | {
|
---|
51 | public:
|
---|
52 |
|
---|
53 | PseudoRandomGenerator(int numSamples, float radius);
|
---|
54 |
|
---|
55 | virtual void Generate(float *samples) const;
|
---|
56 |
|
---|
57 | protected:
|
---|
58 |
|
---|
59 | static HaltonSequence sHalton;
|
---|
60 | };
|
---|
61 |
|
---|
62 |
|
---|
63 | /** This class generates random samples on a disc respecting
|
---|
64 | the poisson disc condition (all samples at least distance d apart)
|
---|
65 | according to some d related to the number of samples.
|
---|
66 | */
|
---|
67 | class PoissonDiscSampleGenerator: public SampleGenerator
|
---|
68 | {
|
---|
69 | public:
|
---|
70 |
|
---|
71 | PoissonDiscSampleGenerator(int numSamples, float radius);
|
---|
72 |
|
---|
73 | virtual void Generate(float *samples) const;
|
---|
74 |
|
---|
75 | protected:
|
---|
76 |
|
---|
77 | static HaltonSequence sHalton;
|
---|
78 | };
|
---|
79 |
|
---|
80 | /** This class generates random spherical samples.
|
---|
81 | */
|
---|
82 | class SphericalSampleGenerator: public SampleGenerator
|
---|
83 | {
|
---|
84 | public:
|
---|
85 |
|
---|
86 | SphericalSampleGenerator(int numSamples, float radius);
|
---|
87 |
|
---|
88 | virtual void Generate(float *samples) const;
|
---|
89 |
|
---|
90 | protected:
|
---|
91 |
|
---|
92 | static HaltonSequence sHalton;
|
---|
93 | };
|
---|
94 |
|
---|
95 |
|
---|
96 | #endif |
---|