Ponca  7d8ac87a7de01d881c9fde3c42e397b44bffb901
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
9#include "./defines.h"
10#include "./primitive.h"
11
12namespace Ponca
13{
14
24 template <class DataPoint, class _NFilter, typename T>
25 class MeanPosition : public T
26 {
27 PONCA_FITTING_DECLARE_DEFAULT_TYPES
28
29 protected:
30 enum
31 {
32 PROVIDES_MEAN_POSITION
33 };
34 VectorType m_sumP{VectorType::Zero()};
36 public:
37 PONCA_EXPLICIT_CAST_OPERATORS(MeanPosition, meanPosition)
38 PONCA_FITTING_DECLARE_INIT
39 PONCA_FITTING_DECLARE_ADDNEIGHBOR
40
47 PONCA_MULTIARCH inline VectorType barycenter() const
48 {
49 return Base::getNeighborFilter().convertToGlobalBasis(barycenterLocal());
50 }
51
55 PONCA_MULTIARCH inline Scalar barycenterDistance() const { return barycenterLocal().norm(); }
56
57 protected:
68 PONCA_MULTIARCH inline VectorType barycenterLocal() const { return (m_sumP / Base::getWeightSum()); }
69
70 }; // class MeanPosition
71
83 template <class DataPoint, class _NFilter, typename T>
84 class MeanNormal : public T
85 {
86 PONCA_FITTING_DECLARE_DEFAULT_TYPES
87
88 protected:
89 enum
90 {
91 PROVIDES_MEAN_NORMAL
92 };
93 VectorType m_sumN{VectorType::Zero()};
95 public:
96 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal, meanNormal)
97 PONCA_FITTING_DECLARE_INIT
98 PONCA_FITTING_DECLARE_ADDNEIGHBOR
99
106 PONCA_MULTIARCH [[nodiscard]] inline VectorType meanNormalVector() const
107 {
108 return (m_sumN / Base::getWeightSum());
109 }
110
111 }; // class MeanNormal
112
125 template <class DataPoint, class _NFilter, int DiffType, typename T>
126 class MeanPositionDer : public T
127 {
128 PONCA_FITTING_DECLARE_DEFAULT_TYPES
129 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
130
131 protected:
132 enum
133 {
134 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE && Base::PROVIDES_MEAN_POSITION,
136 };
137
139 VectorArray m_dSumP{VectorArray::Zero()};
140
141 public:
142 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer, meanPositionDer)
143 PONCA_FITTING_DECLARE_INIT
144 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
145
172 PONCA_MULTIARCH [[nodiscard]] VectorArray barycenterDerivatives() const
173 {
174 return (m_dSumP - Base::barycenterLocal() * Base::m_dSumW) / Base::getWeightSum();
175 }
176
177 }; // class MeanPositionDer
178
191 template <class DataPoint, class _NFilter, int DiffType, typename T>
192 class MeanNormalDer : public T
193 {
194 PONCA_FITTING_DECLARE_DEFAULT_TYPES
195 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
196
197 protected:
198 enum
199 {
200 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE && Base::PROVIDES_MEAN_NORMAL,
202 };
203
205 VectorArray m_dSumN{VectorArray::Zero()};
206
207 public:
208 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer, meanNormalDer)
209 PONCA_FITTING_DECLARE_INIT
210 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
211
239
240 PONCA_MULTIARCH [[nodiscard]] VectorArray dMeanNormal() const
241 {
242 return (m_dSumN - Base::meanNormalVector() * Base::m_dSumW) / Base::getWeightSum();
243 }
244
245 }; // class MeanNormalDer
246
247#include "mean.hpp"
248
249} // namespace Ponca
Compute the derivatives of the input points mean normal.
Definition mean.h:193
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:195
@ PROVIDES_MEAN_NORMAL_DERIVATIVE
Provides derivative of the mean normal.
Definition mean.h:201
Compute the mean normal of the input points.
Definition mean.h:85
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:86
Compute the derivatives of the input points barycenter.
Definition mean.h:127
@ PROVIDES_MEAN_POSITION_DERIVATIVE
Provides derivative of the mean position.
Definition mean.h:135
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:129
Compute the barycenter of the input points.
Definition mean.h:26
VectorType m_sumP
Sum of the input points vectors.
Definition mean.h:34
MeanPosition< DataPoint, _NFilter, T > & meanPosition()
Explicit conversion to MeanPosition , to access methods potentially hidden by heritage.
Definition mean.h:37
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:27
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Scalar barycenterDistance() const
The distance between the barycenter and the basis center.
Definition mean.h:55