Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
TBlackmanHarris2D.h
Go to the documentation of this file.
1#pragma once
2
4#include "Math/constant.h"
5
6#include <Common/assertion.h>
7
8#include <cmath>
9
10namespace ph::math
11{
12
20template<typename Value>
22{
23public:
24 explicit TBlackmanHarris2D(Value radius);
25
26 Value evaluate(Value x, Value y) const override;
27
28private:
29 Value m_reciRadius;
30
31 Value blackmanHarris1D(Value n) const;
32};
33
34template<typename Value>
36 : m_reciRadius(radius > Value(0) ? Value(1) / radius : Value(0))
37{
38 PH_ASSERT(radius > Value(0));
39}
40
41template<typename Value>
42inline Value TBlackmanHarris2D<Value>::evaluate(const Value x, const Value y) const
43{
44 const Value nx = (x * m_reciRadius + Value(1.0)) * Value(0.5);
45 const Value ny = (y * m_reciRadius + Value(1.0)) * Value(0.5);
46
47 return blackmanHarris1D(nx) * blackmanHarris1D(ny);
48}
49
50template<typename Value>
51inline Value TBlackmanHarris2D<Value>::blackmanHarris1D(const Value n) const
52{
53 return
54 Value(0.35875)
55 - Value(0.48829) * std::cos(Value(2.0) * constant::pi<Value> * n)
56 + Value(0.14128) * std::cos(Value(4.0) * constant::pi<Value> * n)
57 - Value(0.01174) * std::cos(Value(6.0) * constant::pi<Value> * n);
58 // ^^^^^^^
59 // NOTE: Originally this coefficient is 0.01168, we modified it like how
60 // appleseed renderer did to make it evaluate to 0 at boundaries.
61}
62
63}// end namespace ph::math
Blackman-Harris window function. A window function similar to Gaussian function in shape....
Definition TBlackmanHarris2D.h:22
TBlackmanHarris2D(Value radius)
Definition TBlackmanHarris2D.h:35
Value evaluate(Value x, Value y) const override
Definition TBlackmanHarris2D.h:42
Definition TMathFunction2D.h:8
constexpr T pi
Value of .
Definition constant.h:15
Math functions and utilities.
Definition TransformInfo.h:10