Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TGaussian2D.h
Go to the documentation of this file.
1#pragma once
2
4
5#include <cmath>
6#include <algorithm>
7
8namespace ph::math
9{
10
11template<typename Value>
12class TGaussian2D : public TMathFunction2D<Value>
13{
14public:
15 TGaussian2D(Value sigmaX, Value sigmaY, Value amplitude);
16
17 Value evaluate(Value x, Value y) const override;
18
22 void setSubmergeAmount(Value amt);
23
24private:
25 Value m_xExpMultiplier;
26 Value m_yExpMultiplier;
27 Value m_amplitude;
28 Value m_submergeAmount;
29};
30
31template<typename Value>
33 const Value sigmaX,
34 const Value sigmaY,
35 const Value amplitude)
36
37 : m_xExpMultiplier(static_cast<Value>(-1) / (static_cast<Value>(2) * sigmaX * sigmaX))
38 , m_yExpMultiplier(static_cast<Value>(-1) / (static_cast<Value>(2) * sigmaY * sigmaY))
39 , m_amplitude (amplitude)
40 , m_submergeAmount(0)
41{}
42
43template<typename Value>
44inline Value TGaussian2D<Value>::evaluate(const Value x, const Value y) const
45{
46 const Value func = m_amplitude * std::exp(m_xExpMultiplier * x * x + m_yExpMultiplier * y * y);
47 return std::max(func - m_submergeAmount, static_cast<Value>(0));
48}
49
50template<typename Value>
51inline void TGaussian2D<Value>::setSubmergeAmount(const Value amt)
52{
53 m_submergeAmount = amt;
54}
55
56}// end namespace ph::math
Definition TGaussian2D.h:13
TGaussian2D(Value sigmaX, Value sigmaY, Value amplitude)
Definition TGaussian2D.h:32
Value evaluate(Value x, Value y) const override
Definition TGaussian2D.h:44
void setSubmergeAmount(Value amt)
Sink the gaussian with specified amount. Effectively subtract then clamp to zero.
Definition TGaussian2D.h:51
Definition TMathFunction2D.h:8
Math functions and utilities.
Definition TransformInfo.h:10