MCPcopy Create free account
hub / github.com/OpenPathGuidingLibrary/openpgl / SampleStatistics

Class SampleStatistics

openpgl/data/SampleStatistics.h:10–242  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8namespace openpgl
9{
10struct SampleStatistics
11{
12 Point3 mean{0.0f};
13 Vector3 variance{0.0f};
14 float numSamples{0};
15 float numZeroValueSamples{0.0f};
16
17 BBox sampleBounds{openpgl::Vector3(std::numeric_limits<float>::max()), openpgl::Vector3(-std::numeric_limits<float>::max())};
18
19 inline void clear()
20 {
21 mean = Point3(0.0f);
22 variance = Vector3(0.0f);
23 numSamples = 0.0f;
24 numZeroValueSamples = 0.0f;
25 sampleBounds.lower = openpgl::Vector3(std::numeric_limits<float>::max());
26 sampleBounds.upper = openpgl::Vector3(-std::numeric_limits<float>::max());
27 }
28
29 inline void addSample(const Point3 sample)
30 {
31 numSamples++;
32 float incWeight = 1.f / float(numSamples);
33 OPENPGL_ASSERT(numSamples > 0.0f);
34 OPENPGL_ASSERT(embree::isvalid(incWeight));
35 OPENPGL_ASSERT(incWeight >= 0.0f);
36
37 const Point3 oldMean = mean;
38 mean += (sample - oldMean) * incWeight;
39 variance += (((sample - oldMean) * (sample - mean)) - variance) * incWeight;
40 sampleBounds.extend(sample);
41 OPENPGL_ASSERT(isValid());
42 }
43
44 inline Point3 getMean() const
45 {
46 return mean;
47 }
48
49 inline Vector3 getVariance() const
50 {
51 return variance;
52 }
53
54 inline BBox getSampleBounds() const
55 {
56 return sampleBounds;
57 }
58
59 inline Vector3 getSampleBoundsExtend() const
60 {
61 return sampleBounds.upper - sampleBounds.lower;
62 }
63
64 inline bool hasValidBoundRange() const
65 {
66 bool validBoundRange = false;
67 Vector3 boundExtend = sampleBounds.upper - sampleBounds.lower;

Callers 1

Calls 2

Vector3Function · 0.85
maxFunction · 0.50

Tested by

no test coverage detected