Ponca  624fc013d41bc7b7ad27159d1c16f7ce57f5a2e4
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightKernel.h
1/*
2 This Source Code Form is subject to the terms of the Mozilla Public
3 License, v. 2.0. If a copy of the MPL was not distributed with this
4 file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6#pragma once
7
8#include "./defines.h"
9
15namespace Ponca
16{
22template <typename _Scalar>
24{
25public:
27 typedef _Scalar Scalar;
28
29 // Init
31 PONCA_MULTIARCH inline ConstantWeightKernel(const Scalar& _value = Scalar(1.)) : m_y(_value){}
33 PONCA_MULTIARCH inline void setValue(const Scalar& _value){ m_y = _value; }
34
35 // Functor
37 PONCA_MULTIARCH inline Scalar f (const Scalar&) const { return m_y; }
39 PONCA_MULTIARCH inline Scalar df (const Scalar&) const { return Scalar(0.); }
41 PONCA_MULTIARCH inline Scalar ddf(const Scalar&) const { return Scalar(0.); }
42
44 static constexpr bool isDValid = true;
46 static constexpr bool isDDValid = true;
47
48private:
49 Scalar m_y;
50};// class ConstantWeightKernel
51
52
59template <typename _Scalar>
61{
62public:
64 typedef _Scalar Scalar;
65
66 // Functor
68 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x - Scalar(1.); return v*v; }
70 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { return Scalar(4.)*_x*(_x*_x-Scalar(1.)); }
72 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const { return Scalar(12.)*_x*_x - Scalar(4.); }
74 static constexpr bool isDValid = true;
76 static constexpr bool isDDValid = true;
77};//class SmoothWeightKernel
78
84template <typename _Scalar, int m, int n>
86{
87public:
88
90 typedef _Scalar Scalar;
91 // Functor
93 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { return pow(pow(_x, n) - Scalar(1.), m); }
95 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { return pow(m*n*_x, n-1) * pow(pow(_x, n) -1, m-1); }
97 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const { return (m-1)*m*n*n*pow(_x, 2*n-2)*pow(pow(_x, n)-1, m-2) + m*(n-1)*n*pow(_x, n-2) * pow(pow(_x, n)-1, m-1); }
99 static constexpr bool isDValid = true;
101 static constexpr bool isDDValid = true;
102};//class PolynomialSmoothWeightKernel
103
112template <typename _Scalar>
114{
115public:
117 typedef _Scalar Scalar;
118
119 // Functor
121 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
122 const Scalar v = Scalar(1.) - _x;
123 return v * v * v * v * ((Scalar(4.) * _x) + Scalar(1.));
124 }
126 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
127 const Scalar v = _x - Scalar(1.);
128 return Scalar(20.) * _x * v * v * v;
129 }
131 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
132 const Scalar v = _x - Scalar(1.);
133 return v * v * (Scalar(80.) * _x - Scalar(20));
134 }
136 static constexpr bool isDValid = true;
138 static constexpr bool isDDValid = true;
139};//class WendlandWeightKernel
140
141
150template <typename _Scalar>
152{
153public:
155 typedef _Scalar Scalar;
156
157 // Functor
159 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const {
160 return Scalar(1.) / (_x * _x);
161 }
163 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const {
164 return Scalar(-2.) / (_x * _x * _x);
165 }
167 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
168 return Scalar(6.) / (_x * _x * _x * _x);
169 }
171 static constexpr bool isDValid = true;
173 static constexpr bool isDDValid = true;
174};//class SingularWeightKernel
175
176
186template <typename _Scalar>
188{
189public:
191 typedef _Scalar Scalar;
192
193 // Functor
197 PONCA_MULTIARCH inline Scalar f (const Scalar& _x) const { Scalar v = _x*_x; return exp(-v/(Scalar(1)-v)); }
201 PONCA_MULTIARCH inline Scalar df (const Scalar& _x) const { Scalar v = _x*_x; Scalar mv = v-Scalar(1); return -(Scalar(2) * exp(v/mv) * _x)/(mv*mv); }
206 PONCA_MULTIARCH inline Scalar ddf(const Scalar& _x) const {
207 Scalar v = _x*_x; // x^2
208 Scalar mv = v-Scalar(1); // x^2-1
209 Scalar mvpow = Scalar(2)/mv; // 2/(x^2-1)
210 Scalar cmvpow = pow(_x,mvpow); // x^{2/(x^2-1)}
211 return Scalar(2) * exp(cmvpow) * ((Scalar(4) * pow(_x,mvpow + Scalar(2)) * log(_x) - mv * (-Scalar(3) * v + Scalar(2) * cmvpow - Scalar(1))))/(mv*mv*mv*mv);
212 }
213
215 static constexpr bool isDValid = true;
217 static constexpr bool isDDValid = false;
218};//class CompactExpWeightKernel
219
220
221}// namespace Ponca
Compact Exponential WeightKernel defined in .
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is not defined and valid on the definition interval
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
_Scalar Scalar
Scalar type defined outside the class.
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Concept::WeightKernelConcept returning a constant value.
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &) const
Return .
Scalar ddf(const Scalar &) const
Return .
Scalar f(const Scalar &) const
Return the constant value.
static constexpr bool isDValid
df is defined and valid on the definition interval
void setValue(const Scalar &_value)
Set the returned value.
_Scalar Scalar
Scalar type defined outside the class.
ConstantWeightKernel(const Scalar &_value=Scalar(1.))
Default constructor that could be used to set the returned value.
Generalised version of SmoothWeightKernel with arbitrary degrees : .
static constexpr bool isDValid
df is defined and valid on the definition interval
_Scalar Scalar
Scalar type defined outside the class.
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
Singular WeightKernel defined in .
Scalar ddf(const Scalar &_x) const
Defines the Singular second order weighting function .
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &_x) const
Defines the Singular first order weighting function .
Scalar f(const Scalar &_x) const
Defines the Singular weighting function .
_Scalar Scalar
Scalar type defined outside the class.
static constexpr bool isDValid
df is defined and valid on the definition interval
Smooth WeightKernel of 2nd degree, defined in Special case of PolynomialSmoothWeightKernel<Scalar,...
Scalar df(const Scalar &_x) const
Defines the smooth first order weighting function .
Scalar f(const Scalar &_x) const
Defines the smooth weighting function .
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar ddf(const Scalar &_x) const
Defines the smooth second order weighting function .
_Scalar Scalar
Scalar type defined outside the class.
Wendland WeightKernel defined in .
_Scalar Scalar
Scalar type defined outside the class.
static constexpr bool isDValid
df is defined and valid on the definition interval
static constexpr bool isDDValid
ddf is defined and valid on the definition interval
Scalar df(const Scalar &_x) const
Defines the Wendland first order weighting function .
Scalar ddf(const Scalar &_x) const
Defines the Wendland second order weighting function .
Scalar f(const Scalar &_x) const
Defines the Wendland weighting function .
This Source Code Form is subject to the terms of the Mozilla Public License, v.