Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
PDF.h
Go to the documentation of this file.
1#pragma once
2
3#include "Core/LTA/enums.h"
4
5#include <Common/assertion.h>
6#include <Common/primitive_type.h>
7
8namespace ph::lta
9{
10
13class PDF final
14{
15public:
18 real value = 0.0_r;
19
24
28 static PDF W(real pdfW);
29
33 static PDF A(real pdfA);
34
38 static PDF D(real pdfD);
39
40 real getPdfW() const;
41 real getPdfA() const;
42 real getPdfD() const;
43
49 bool isEmpty() const;
50
55 real operator * () const;
56
60 operator bool () const;
61
65 PDF operator + (real rhs) const;
66 PDF operator - (real rhs) const;
67 PDF operator * (real rhs) const;
68 PDF operator / (real rhs) const;
70};
71
72inline PDF PDF::W(const real pdfW)
73{
74 return {.value = pdfW, .domain = EDomain::SolidAngle};
75}
76
77inline PDF PDF::A(const real pdfA)
78{
79 return {.value = pdfA, .domain = EDomain::Area};
80}
81
82inline PDF PDF::D(const real pdfD)
83{
84 return {.value = pdfD, .domain = EDomain::Discrete};
85}
86
87inline real PDF::getPdfW() const
88{
89 PH_ASSERT(domain == EDomain::SolidAngle);
90 return value;
91}
92
93inline real PDF::getPdfA() const
94{
95 PH_ASSERT(domain == EDomain::Area);
96 return value;
97}
98
99inline real PDF::getPdfD() const
100{
101 PH_ASSERT(domain == EDomain::Discrete);
102 return value;
103}
104
105inline bool PDF::isEmpty() const
106{
107 return domain == EDomain::Empty;
108}
109
110inline real PDF::operator * () const
111{
112 PH_ASSERT(!isEmpty());
113 return value;
114}
115
116inline PDF::operator bool () const
117{
118 return !isEmpty() && std::isfinite(value) && value > 0;
119}
120
121inline PDF PDF::operator + (const real rhs) const
122{
123 PH_ASSERT(!isEmpty());
124 return {.value = value + rhs, .domain = domain};
125}
126
127inline PDF PDF::operator - (const real rhs) const
128{
129 PH_ASSERT(!isEmpty());
130 return {.value = value - rhs, .domain = domain};
131}
132
133inline PDF PDF::operator * (const real rhs) const
134{
135 PH_ASSERT(!isEmpty());
136 return {.value = value * rhs, .domain = domain};
137}
138
139inline PDF PDF::operator / (const real rhs) const
140{
141 PH_ASSERT(!isEmpty());
142 return {.value = value / rhs, .domain = domain};
143}
144
145}// end namespace ph::lta
A sample from a Probability Density Function (PDF).
Definition PDF.h:14
PDF operator-(real rhs) const
Definition PDF.h:127
PDF operator/(real rhs) const
Definition PDF.h:139
static PDF A(real pdfA)
Definition PDF.h:77
real getPdfD() const
Definition PDF.h:99
static PDF D(real pdfD)
Definition PDF.h:82
real operator*() const
Definition PDF.h:110
real getPdfW() const
Definition PDF.h:87
static PDF W(real pdfW)
Definition PDF.h:72
real value
Definition PDF.h:18
EDomain domain
Definition PDF.h:23
PDF operator+(real rhs) const
Perform arithmetic on value without changing its domain.
Definition PDF.h:121
bool isEmpty() const
Definition PDF.h:105
real getPdfA() const
Definition PDF.h:93
Light transport algorithms.
Definition enums.h:6
EDomain
Type of the set of all possible inputs for a mathematical function.
Definition enums.h:19