Ponca  f7f7d7cc113b4e53be6bee25005fbdbe7e016293
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 VectorType & _evalPos = VectorType::Zero(),
45 const Scalar& _t = Scalar(1.))
46 : m_t(_t), m_p(_evalPos)
47 {
48 //\todo manage that assert on __host__ and __device__
49 //assert(_t > Scalar(0));
50 }
51
53 PONCA_MULTIARCH inline const VectorType& basisCenter() const { return m_p; }
54
60 PONCA_MULTIARCH inline VectorType convertToGlobalBasis(const VectorType& _q) const;
61
67 PONCA_MULTIARCH inline VectorType convertToLocalBasis(const VectorType& _q) const;
68
83 PONCA_MULTIARCH inline WeightReturnType w(const VectorType& _q,
84 const DataPoint& /*attributes*/) const;
85
86
102 PONCA_MULTIARCH inline VectorType spacedw(const VectorType& _q,
103 const DataPoint& /*attributes*/) const;
104
105
126 PONCA_MULTIARCH inline MatrixType spaced2w(const VectorType& _q,
127 const DataPoint& /*attributes*/) const;
128
143 PONCA_MULTIARCH inline Scalar scaledw(const VectorType& _q,
144 const DataPoint& /*attributes*/) const;
145
164 PONCA_MULTIARCH inline Scalar scaled2w(const VectorType& _q,
165 const DataPoint& /*attributes*/) const;
166
186 PONCA_MULTIARCH inline VectorType scaleSpaced2w(const VectorType& _q,
187 const DataPoint& /*attributes*/) const;
188
190 PONCA_MULTIARCH inline Scalar evalScale() const { return m_t; }
191
193 PONCA_MULTIARCH inline const VectorType & evalPos() const { return m_p; }
194
195protected:
197 WeightKernel m_wk;
200};// class DistWeightFunc
201
202
209template <class DataPoint>
211{
212public:
214 using Scalar = typename DataPoint::Scalar;
216 using VectorType = typename DataPoint::VectorType;
218 using MatrixType = typename DataPoint::MatrixType;
220 using WeightReturnType = PONCA_MULTIARCH_CU_STD_NAMESPACE(pair)<Scalar, VectorType>;
221
225 PONCA_MULTIARCH inline NoWeightFunc(const VectorType & _evalPos = VectorType::Zero()) : m_p(_evalPos){ }
226
231 PONCA_MULTIARCH inline void init( const VectorType& _evalPos = VectorType::Zero() ) { m_p = _evalPos; }
232
233 PONCA_MULTIARCH inline const VectorType& basisCenter() const
234 { return m_p; }
235
237 PONCA_MULTIARCH inline VectorType convertToLocalBasis(const VectorType& _q) const
238 { return _q - m_p; }
239
244 PONCA_MULTIARCH inline WeightReturnType w(const VectorType& _q,
245 const DataPoint& /*attributes*/) const
246 {
248 return {Scalar(1), q};
249 }
250
251
256 PONCA_MULTIARCH inline VectorType spacedw(const VectorType& /*_q*/,
257 const DataPoint& /*attributes*/) const
258 { return VectorType::Zeros(); }
259
260
265 PONCA_MULTIARCH inline MatrixType spaced2w(const VectorType& /*_q*/,
266 const DataPoint& /*attributes*/) const
267 { return MatrixType::Zeros(); }
268
273 PONCA_MULTIARCH inline Scalar scaledw(const VectorType& /*_q*/,
274 const DataPoint& /*attributes*/) const
275 { return Scalar(0); }
276
281 PONCA_MULTIARCH inline Scalar scaled2w(const VectorType& /*_q*/,
282 const DataPoint& /*attributes*/) const
283 { return Scalar(0); }
284
290 PONCA_MULTIARCH inline VectorType scaleSpaced2w(const VectorType& /*_q*/,
291 const DataPoint& /*attributes*/) const
292 { return VectorType::Zeros(); }
293
294private:
295 VectorType m_p;
296};// class DistWeightFunc
297
298#include "weightFunc.hpp"
299
300}// 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(.
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
DistWeightFunc(const VectorType &_evalPos=VectorType::Zero(), const Scalar &_t=Scalar(1.))
Constructor that defines the current evaluation scale.
Definition weightFunc.h:44
Scalar evalScale() const
Access to the evaluation scale set during the initialization.
Definition weightFunc.h:190
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:53
WeightKernel m_wk
1D function applied to weight queries
Definition weightFunc.h:197
Scalar m_t
Evaluation scale.
Definition weightFunc.h:196
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:193
VectorType m_p
basis center
Definition weightFunc.h:198
Weighting function that set uniform weight to all samples.
Definition weightFunc.h:211
Scalar scaled2w(const VectorType &, const DataPoint &) const
Second order derivative in scale , which are always $0$.
Definition weightFunc.h:281
MatrixType spaced2w(const VectorType &, const DataPoint &) const
Second order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:265
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:218
WeightReturnType w(const VectorType &_q, const DataPoint &) const
Compute the weight of the given query, which is always $1$.
Definition weightFunc.h:244
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:290
Scalar scaledw(const VectorType &, const DataPoint &) const
First order derivative in scale , which are always $0$.
Definition weightFunc.h:273
NoWeightFunc(const VectorType &_evalPos=VectorType::Zero())
Constructor that defines the current evaluation scale.
Definition weightFunc.h:225
VectorType convertToLocalBasis(const VectorType &_q) const
Convert query from global to local coordinate system.
Definition weightFunc.h:237
VectorType spacedw(const VectorType &, const DataPoint &) const
First order derivative in space (for each spatial dimension , which are always $0$.
Definition weightFunc.h:256
void init(const VectorType &_evalPos=VectorType::Zero())
Initialization method, called by the fitting procedure.
Definition weightFunc.h:231
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:216
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method w()
Definition weightFunc.h:220
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:214
This Source Code Form is subject to the terms of the Mozilla Public License, v.