Ponca  a3bcca651499c602bd353676d4b50af3643c4cad
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightFunc.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
7#pragma once
8
9#include "./defines.h"
10#include PONCA_MULTIARCH_INCLUDE_CU_STD(utility)
11
12namespace Ponca
13{
27template <class DataPoint, class WeightKernel>
29{
30public:
32 using Scalar = typename DataPoint::Scalar;
34 using VectorType = typename DataPoint::VectorType;
36 using MatrixType = typename DataPoint::MatrixType;
38 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
39
44 PONCA_MULTIARCH inline DistWeightFunc(const Scalar& _t = Scalar(1.))
45 : m_p(VectorType::Zero())
46 {
47 //\todo manage that assrt on __host__ and __device__
48 //assert(_t > Scalar(0));
49 m_t = _t;
50 }
51
56 PONCA_MULTIARCH inline void init( const VectorType& _evalPos )
57 {
58 m_p = _evalPos;
59 }
60
62 PONCA_MULTIARCH inline const VectorType& basisCenter() const { return m_p; }
63
69 PONCA_MULTIARCH inline VectorType convertToGlobalBasis(const VectorType& _q) const;
70
76 PONCA_MULTIARCH inline VectorType convertToLocalBasis(const VectorType& _q) const;
77
92 PONCA_MULTIARCH inline WeightReturnType w(const VectorType& _q,
93 const DataPoint& /*attributes*/) const;
94
95
111 PONCA_MULTIARCH inline VectorType spacedw(const VectorType& _q,
112 const DataPoint& /*attributes*/) const;
113
114
135 PONCA_MULTIARCH inline MatrixType spaced2w(const VectorType& _q,
136 const DataPoint& /*attributes*/) const;
137
152 PONCA_MULTIARCH inline Scalar scaledw(const VectorType& _q,
153 const DataPoint& /*attributes*/) const;
154
173 PONCA_MULTIARCH inline Scalar scaled2w(const VectorType& _q,
174 const DataPoint& /*attributes*/) const;
175
195 PONCA_MULTIARCH inline VectorType scaleSpaced2w(const VectorType& _q,
196 const DataPoint& /*attributes*/) const;
197
199 PONCA_MULTIARCH inline Scalar evalScale() const { return m_t; }
200
202 PONCA_MULTIARCH inline const VectorType & evalPos() const { return m_p; }
203
204protected:
206 WeightKernel m_wk;
209};// class DistWeightFunc
210
211
218template <class DataPoint>
220{
221public:
223 using Scalar = typename DataPoint::Scalar;
225 using VectorType = typename DataPoint::VectorType;
227 using MatrixType = typename DataPoint::MatrixType;
229 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
230
234 PONCA_MULTIARCH inline NoWeightFunc(const Scalar& /*_t*/ = Scalar(0) ) : m_p(VectorType::Zero()){ }
235
240 PONCA_MULTIARCH inline void init( const VectorType& _evalPos = VectorType::Zero() ) { m_p = _evalPos; }
241
242 PONCA_MULTIARCH inline const VectorType& basisCenter() const
243 { return m_p; }
244
246 PONCA_MULTIARCH inline VectorType convertToLocalBasis(const VectorType& _q) const
247 { return _q - m_p; }
248
253 PONCA_MULTIARCH inline WeightReturnType w(const VectorType& _q,
254 const DataPoint& /*attributes*/) const
255 {
257 return {Scalar(1), q};
258 }
259
260
265 PONCA_MULTIARCH inline VectorType spacedw(const VectorType& /*_q*/,
266 const DataPoint& /*attributes*/) const
267 { return VectorType::Zeros(); }
268
269
274 PONCA_MULTIARCH inline MatrixType spaced2w(const VectorType& /*_q*/,
275 const DataPoint& /*attributes*/) const
276 { return MatrixType::Zeros(); }
277
282 PONCA_MULTIARCH inline Scalar scaledw(const VectorType& /*_q*/,
283 const DataPoint& /*attributes*/) const
284 { return Scalar(0); }
285
290 PONCA_MULTIARCH inline Scalar scaled2w(const VectorType& /*_q*/,
291 const DataPoint& /*attributes*/) const
292 { return Scalar(0); }
293
299 PONCA_MULTIARCH inline VectorType scaleSpaced2w(const VectorType& /*_q*/,
300 const DataPoint& /*attributes*/) const
301 { return VectorType::Zeros(); }
302
303private:
304 VectorType m_p;
305};// class DistWeightFunc
306
307#include "weightFunc.hpp"
308
309}// namespace Ponca
Weighting function based on the euclidean distance between a query and a reference position.
Definition weightFunc.h:29
VectorType convertToLocalBasis(const VectorType &_q) const
Convert query from global to local coordinate system (used internally(.
DistWeightFunc(const Scalar &_t=Scalar(1.))
Constructor that defines the current evaluation scale.
Definition weightFunc.h:44
Scalar scaledw(const VectorType &_q, const DataPoint &) const
First order derivative in scale .
Scalar scaled2w(const VectorType &_q, const DataPoint &) const
Second order derivative in scale .
VectorType scaleSpaced2w(const VectorType &_q, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension .
MatrixType spaced2w(const VectorType &_q, const DataPoint &) const
Second order derivative in space (for each spatial dimension .
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:36
Scalar evalScale() const
Access to the evaluation scale set during the initialization.
Definition weightFunc.h:199
WeightReturnType w(const VectorType &_q, const DataPoint &) const
Compute the weight of the given query with respect to its coordinates.
VectorType convertToGlobalBasis(const VectorType &_q) const
Convert position from local to global coordinate system.
VectorType spacedw(const VectorType &_q, const DataPoint &) const
First order derivative in space (for each spatial dimension .
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method w()
Definition weightFunc.h:38
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:32
const VectorType & basisCenter() const
Get access to basis center location in global coordinate system.
Definition weightFunc.h:62
WeightKernel m_wk
1D function applied to weight queries
Definition weightFunc.h:206
Scalar m_t
Evaluation scale.
Definition weightFunc.h:205
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:34
const VectorType & evalPos() const
Access to the evaluation position set during the initialization.
Definition weightFunc.h:202
VectorType m_p
basis center
Definition weightFunc.h:207
void init(const VectorType &_evalPos)
Initialization method, called by the fitting procedure.
Definition weightFunc.h:56
Weighting function that set uniform weight to all samples.
Definition weightFunc.h:220
Scalar scaled2w(const VectorType &, const DataPoint &) const
Second order derivative in scale , which are always $0$.
Definition weightFunc.h:290
MatrixType spaced2w(const VectorType &, const DataPoint &) const
Second order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:274
NoWeightFunc(const Scalar &=Scalar(0))
Constructor that defines the current evaluation scale.
Definition weightFunc.h:234
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:227
WeightReturnType w(const VectorType &_q, const DataPoint &) const
Compute the weight of the given query, which is always $1$.
Definition weightFunc.h:253
VectorType scaleSpaced2w(const VectorType &, const DataPoint &) const
Cross derivative in scale and in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:299
Scalar scaledw(const VectorType &, const DataPoint &) const
First order derivative in scale , which are always $0$.
Definition weightFunc.h:282
VectorType convertToLocalBasis(const VectorType &_q) const
Convert query from global to local coordinate system.
Definition weightFunc.h:246
VectorType spacedw(const VectorType &, const DataPoint &) const
First order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:265
void init(const VectorType &_evalPos=VectorType::Zero())
Initialization method, called by the fitting procedure.
Definition weightFunc.h:240
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:225
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method w()
Definition weightFunc.h:229
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:223
This Source Code Form is subject to the terms of the Mozilla Public License, v.