Ponca  8e4373a7fc557bbfb1afb9210d70f03872388d04
Point Cloud Analysis library
Loading...
Searching...
No Matches
weightFunc.hpp
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
9template <class DataPoint, class WeightKernel>
10typename DistWeightFunc<DataPoint, WeightKernel>::WeightReturnType
12{
13 const auto lq = NeighborhoodFrame::convertToLocalBasis(_q.pos());
14 Scalar d = lq.norm();
15 if (isCompact) // compile-time branching
16 return { (d <= m_t) ? m_wk.f(d/m_t) : Scalar(0.), lq };
17 else
18 return {m_wk.f(d/m_t), lq};
19}
20
21template <class DataPoint, class WeightKernel>
24 const DataPoint&) const
25{
26 static_assert(WeightKernel::isDValid, "First order derivatives are required");
27 VectorType result = VectorType::Zero();
28 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
29 Scalar d = q.norm();
30 // isCompact is tested at compile-time
31 if ((!isCompact) || (d <= m_t && d != Scalar(0.))) result = (q / (d * m_t)) * m_wk.df(d / m_t);
32 return result;
33}
34
35template <class DataPoint, class WeightKernel>
38 const DataPoint&) const
39{
40 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
41 MatrixType result = MatrixType::Zero();
42 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
43 Scalar d = q.norm();
44 if ((!isCompact) ||(d <= m_t && d != Scalar(0.)))
45 {
46 Scalar der = m_wk.df(d/m_t);
47 result = q*q.transpose()/d*(m_wk.ddf(d/m_t)/m_t - der/d);
48 result.diagonal().array() += der;
49 result *= Scalar(1.)/(m_t*d);
50 }
51 return result;
52}
53
54template <class DataPoint, class WeightKernel>
57 const DataPoint&) const
58{
59 static_assert(WeightKernel::isDValid, "First order derivatives are required");
60 Scalar d = NeighborhoodFrame::convertToLocalBasis(_q).norm();
61 return ((!isCompact) ||(d <= m_t)) ? Scalar( - d*m_wk.df(d/m_t)/(m_t*m_t) ) : Scalar(0.);
62}
63
64template <class DataPoint, class WeightKernel>
67 const DataPoint&) const
68{
69 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
70 Scalar d = NeighborhoodFrame::convertToLocalBasis(_q).norm();
71 return ((!isCompact) ||(d <= m_t)) ? Scalar(Scalar(2.)*d/(m_t*m_t*m_t)*m_wk.df(d/m_t) +
72 d*d/(m_t*m_t*m_t*m_t)*m_wk.ddf(d/m_t)) :
73 Scalar(0.);
74}
75
76template <class DataPoint, class WeightKernel>
79 const DataPoint&) const
80{
81 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
82 VectorType result = VectorType::Zero();
83 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
84 Scalar d = q.norm();
85 if ((!isCompact) ||(d <= m_t && d != Scalar(0.)))
86 result = -q/(m_t*m_t)*(m_wk.df(d/m_t)/d + m_wk.ddf(d/m_t)/m_t);
87 return result;
88}
89
90
Weight neighbors according to the euclidean distance between a query and a reference position.
Definition weightFunc.h:127
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:134
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:130
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:132