Ponca  6f9f1b59d7c8c4654a710cfcef7342f4f5c79ba1
Point Cloud Analysis library
Loading...
Searching...
No Matches
mean.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#include "../../defines.h"
9#include "../concepts.h"
10
11#define MEAN_POSITION_DER_REQUIREMENTS ProvidesBasketDiffUnitBase<T>&& ProvidesMeanPosition<T>
12#define MEAN_NORMAL_DER_REQUIREMENTS ProvidesBasketDiffUnitBase<T>&& ProvidesMeanNormal<T>
13
14namespace Ponca
15{
16
26 template <class DataPoint, class _NFilter, typename T>
27 class MeanPosition : public T
28 {
29 PONCA_FITTING_DECLARE_DEFAULT_TYPES
30
31 protected:
32 VectorType m_sumP{VectorType::Zero()};
34 public:
35 PONCA_EXPLICIT_CAST_OPERATORS(MeanPosition, meanPosition)
36 PONCA_FITTING_DECLARE_INIT
37 PONCA_FITTING_DECLARE_ADDNEIGHBOR
38
45 PONCA_MULTIARCH inline VectorType barycenter() const
46 {
47 return Base::getNeighborFrame().convertToGlobalBasis(barycenterLocal());
48 }
49
53 PONCA_MULTIARCH inline Scalar barycenterDistance() const { return barycenterLocal().norm(); }
54
55 protected:
66 PONCA_MULTIARCH inline VectorType barycenterLocal() const { return (m_sumP / Base::getWeightSum()); }
67
68 }; // class MeanPosition
69
80 template <class DataPoint, class _NFilter, typename T>
81 class MeanNormal : public T
82 {
83 PONCA_FITTING_DECLARE_DEFAULT_TYPES
84
85 protected:
86 VectorType m_sumN{VectorType::Zero()};
88 public:
89 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal, meanNormal)
90 PONCA_FITTING_DECLARE_INIT
91 PONCA_FITTING_DECLARE_ADDNEIGHBOR
92
99 PONCA_MULTIARCH [[nodiscard]] inline VectorType meanNormalVector() const
100 {
101 return (m_sumN / Base::getWeightSum());
102 }
103
104 }; // class MeanNormal
105
118 template <class DataPoint, class _NFilter, int DiffType, typename T>
119 requires MEAN_POSITION_DER_REQUIREMENTS
120 class MeanPositionDer : public T
121 {
122 PONCA_FITTING_DECLARE_DEFAULT_TYPES
123 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
124
125 protected:
127 VectorArray m_dSumP{VectorArray::Zero()};
128
129 public:
130 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer, meanPositionDer)
131 PONCA_FITTING_DECLARE_INIT
132 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
133
160 PONCA_MULTIARCH [[nodiscard]] VectorArray barycenterDerivatives() const
161 {
162 return (m_dSumP - Base::barycenterLocal() * Base::m_dSumW) / Base::getWeightSum();
163 }
164
165 }; // class MeanPositionDer
166
179 template <class DataPoint, class _NFilter, int DiffType, typename T>
180 requires MEAN_NORMAL_DER_REQUIREMENTS
181 class MeanNormalDer : public T
182 {
183 PONCA_FITTING_DECLARE_DEFAULT_TYPES
184 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
185
186 protected:
188 VectorArray m_dSumN{VectorArray::Zero()};
189
190 public:
191 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer, meanNormalDer)
192 PONCA_FITTING_DECLARE_INIT
193 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
194
222
223 PONCA_MULTIARCH [[nodiscard]] VectorArray dMeanNormal() const
224 {
225 return (m_dSumN - Base::meanNormalVector() * Base::m_dSumW) / Base::getWeightSum();
226 }
227
228 }; // class MeanNormalDer
229
230#include "mean.hpp"
231
232} // namespace Ponca
Compute the derivatives of the input points mean normal.
Definition mean.h:182
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:184
Compute the mean normal of the input points.
Definition mean.h:82
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:83
Compute the derivatives of the input points barycenter.
Definition mean.h:121
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:123
Compute the barycenter of the input points.
Definition mean.h:28
VectorType m_sumP
Sum of the input points vectors.
Definition mean.h:32
MeanPosition< DataPoint, _NFilter, T > & meanPosition()
Explicit conversion to MeanPosition , to access methods potentially hidden by heritage.
Definition mean.h:35
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:29
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
Ponca::MeanPosition T barycenter() const
where are all the point samples in 's neighborhood
Definition mean.h:45
Scalar barycenterDistance() const
The distance between the barycenter and the basis center.
Definition mean.h:53