Ponca  82fc77e8c6294111c6f00670e92ec58a24e2ecf2
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_NORMAL_REQUIREMENTS ProvidesNormal<DataPoint>
12#define MEAN_POSITION_DER_REQUIREMENTS ProvidesBasketDiffUnitBase<T>&& ProvidesMeanPosition<T>
13#define MEAN_NORMAL_DER_REQUIREMENTS ProvidesBasketDiffUnitBase<T>&& ProvidesMeanNormal<T>
14
15namespace Ponca
16{
17
27 template <class DataPoint, class _NFilter, typename T>
28 class MeanPosition : public T
29 {
30 PONCA_FITTING_DECLARE_DEFAULT_TYPES
31
32 protected:
33 VectorType m_sumP{VectorType::Zero()};
35 public:
36 PONCA_EXPLICIT_CAST_OPERATORS(MeanPosition, meanPosition)
37 PONCA_FITTING_DECLARE_INIT
38 PONCA_FITTING_DECLARE_ADDNEIGHBOR
39
46 PONCA_MULTIARCH inline VectorType barycenter() const
47 {
48 return Base::getNeighborFrame().convertToGlobalBasis(barycenterLocal());
49 }
50
54 PONCA_MULTIARCH inline Scalar barycenterDistance() const { return barycenterLocal().norm(); }
55
56 protected:
67 PONCA_MULTIARCH inline VectorType barycenterLocal() const { return (m_sumP / Base::getWeightSum()); }
68
69 }; // class MeanPosition
70
81 template <class DataPoint, class _NFilter, typename T>
82 requires MEAN_NORMAL_REQUIREMENTS
83 class MeanNormal : public T
84 {
85 PONCA_FITTING_DECLARE_DEFAULT_TYPES
86
87 protected:
88 VectorType m_sumN{VectorType::Zero()};
90 public:
91 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal, meanNormal)
92 PONCA_FITTING_DECLARE_INIT
93 PONCA_FITTING_DECLARE_ADDNEIGHBOR
94
101 PONCA_MULTIARCH [[nodiscard]] inline VectorType meanNormalVector() const
102 {
103 return (m_sumN / Base::getWeightSum());
104 }
105
106 }; // class MeanNormal
107
120 template <class DataPoint, class _NFilter, int DiffType, typename T>
121 requires MEAN_POSITION_DER_REQUIREMENTS
122 class MeanPositionDer : public T
123 {
124 PONCA_FITTING_DECLARE_DEFAULT_TYPES
125 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
126
127 protected:
129 VectorArray m_dSumP{VectorArray::Zero()};
130
131 public:
132 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer, meanPositionDer)
133 PONCA_FITTING_DECLARE_INIT
134 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
135
162 PONCA_MULTIARCH [[nodiscard]] VectorArray barycenterDerivatives() const
163 {
164 return (m_dSumP - Base::barycenterLocal() * Base::m_dSumW) / Base::getWeightSum();
165 }
166
167 }; // class MeanPositionDer
168
181 template <class DataPoint, class _NFilter, int DiffType, typename T>
182 requires MEAN_NORMAL_DER_REQUIREMENTS
183 class MeanNormalDer : public T
184 {
185 PONCA_FITTING_DECLARE_DEFAULT_TYPES
186 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
187
188 protected:
190 VectorArray m_dSumN{VectorArray::Zero()};
191
192 public:
193 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer, meanNormalDer)
194 PONCA_FITTING_DECLARE_INIT
195 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
196
224
225 PONCA_MULTIARCH [[nodiscard]] VectorArray dMeanNormal() const
226 {
227 return (m_dSumN - Base::meanNormalVector() * Base::m_dSumW) / Base::getWeightSum();
228 }
229
230 }; // class MeanNormalDer
231
232#include "mean.hpp"
233
234} // namespace Ponca
Compute the derivatives of the input points mean normal.
Definition mean.h:184
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:186
Compute the mean normal of the input points.
Definition mean.h:84
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:85
Compute the derivatives of the input points barycenter.
Definition mean.h:123
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:125
Compute the barycenter of the input points.
Definition mean.h:29
VectorType m_sumP
Sum of the input points vectors.
Definition mean.h:33
MeanPosition< DataPoint, _NFilter, T > & meanPosition()
Explicit conversion to MeanPosition , to access methods potentially hidden by heritage.
Definition mean.h:36
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:30
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:46
Scalar barycenterDistance() const
The distance between the barycenter and the basis center.
Definition mean.h:54