Ponca  bab7704293a2c36e5bed9dea40def7ba839bfe08
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>
11 const DataPoint& _q) const
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>
23 const VectorType& _q, const DataPoint&) const
24{
25 static_assert(WeightKernel::isDValid, "First order derivatives are required");
26 VectorType result = VectorType::Zero();
27 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
28 Scalar d = q.norm();
29 // isCompact is tested at compile-time
30 if ((!isCompact) || (d <= m_t && d != Scalar(0.)))
31 result = (q / (d * m_t)) * m_wk.df(d / m_t);
32 return result;
33}
34
35template <class DataPoint, class WeightKernel>
37 const VectorType& _q, const DataPoint&) const
38{
39 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
40 MatrixType result = MatrixType::Zero();
41 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
42 Scalar d = q.norm();
43 if ((!isCompact) || (d <= m_t && d != Scalar(0.)))
44 {
45 Scalar der = m_wk.df(d / m_t);
46 result = q * q.transpose() / d * (m_wk.ddf(d / m_t) / m_t - der / d);
47 result.diagonal().array() += der;
48 result *= Scalar(1.) / (m_t * d);
49 }
50 return result;
51}
52
53template <class DataPoint, class WeightKernel>
55 const VectorType& _q, const DataPoint&) const
56{
57 static_assert(WeightKernel::isDValid, "First order derivatives are required");
58 Scalar d = NeighborhoodFrame::convertToLocalBasis(_q).norm();
59 return ((!isCompact) || (d <= m_t)) ? Scalar(-d * m_wk.df(d / m_t) / (m_t * m_t)) : Scalar(0.);
60}
61
62template <class DataPoint, class WeightKernel>
64 const VectorType& _q, const DataPoint&) const
65{
66 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
67 Scalar d = NeighborhoodFrame::convertToLocalBasis(_q).norm();
68 return ((!isCompact) || (d <= m_t)) ? Scalar(Scalar(2.) * d / (m_t * m_t * m_t) * m_wk.df(d / m_t) +
69 d * d / (m_t * m_t * m_t * m_t) * m_wk.ddf(d / m_t))
70 : Scalar(0.);
71}
72
73template <class DataPoint, class WeightKernel>
75 const VectorType& _q, const DataPoint&) const
76{
77 static_assert(WeightKernel::isDDValid, "Second order derivatives are required");
78 VectorType result = VectorType::Zero();
79 const auto q = NeighborhoodFrame::convertToLocalBasis(_q);
80 Scalar d = q.norm();
81 if ((!isCompact) || (d <= m_t && d != Scalar(0.)))
82 result = -q / (m_t * m_t) * (m_wk.df(d / m_t) / d + m_wk.ddf(d / m_t) / m_t);
83 return result;
84}
85
Weight neighbors according to the euclidean distance between a query and a reference position.
Definition weightFunc.h:162
typename DataPoint::MatrixType MatrixType
Matrix type from DataPoint.
Definition weightFunc.h:169
std::pair< Scalar, VectorType > WeightReturnType
Return type of the method #w()
Definition weightFunc.h:171
typename DataPoint::Scalar Scalar
Scalar type from DataPoint.
Definition weightFunc.h:165
typename DataPoint::VectorType VectorType
Vector type from DataPoint.
Definition weightFunc.h:167