Ponca  8e4373a7fc557bbfb1afb9210d70f03872388d04
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
23 template<class DataPoint, class _NFilter, typename T>
24 class MeanPosition : public T {
25 PONCA_FITTING_DECLARE_DEFAULT_TYPES
26
27 protected:
28 enum { PROVIDES_MEAN_POSITION };
29 VectorType m_sumP {VectorType::Zero()};
31 public:
32 PONCA_EXPLICIT_CAST_OPERATORS(MeanPosition,meanPosition)
33 PONCA_FITTING_DECLARE_INIT
34 PONCA_FITTING_DECLARE_ADDNEIGHBOR
35
40 PONCA_MULTIARCH inline VectorType barycenter() const {
41 return Base::getNeighborFilter().convertToGlobalBasis( barycenterLocal() );
42 }
43
47 PONCA_MULTIARCH inline Scalar barycenterDistance() const {
48 return barycenterLocal().norm();
49 }
50
51 protected:
61 PONCA_MULTIARCH inline VectorType barycenterLocal() const {
62 return (m_sumP / Base::getWeightSum());
63 }
64
65 }; //class MeanPosition
66
78 template<class DataPoint, class _NFilter, typename T>
79 class MeanNormal : public T {
80 PONCA_FITTING_DECLARE_DEFAULT_TYPES
81
82 protected:
83 enum { PROVIDES_MEAN_NORMAL };
84 VectorType m_sumN {VectorType::Zero()};
86 public:
87 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal,meanNormal)
88 PONCA_FITTING_DECLARE_INIT
89 PONCA_FITTING_DECLARE_ADDNEIGHBOR
90
95 PONCA_MULTIARCH [[nodiscard]] inline VectorType meanNormalVector() const {
96 return (m_sumN / Base::getWeightSum());
97 }
98
99 }; //class MeanNormal
100
113 template<class DataPoint, class _NFilter, int DiffType, typename T>
114 class MeanPositionDer : public T {
115 PONCA_FITTING_DECLARE_DEFAULT_TYPES
116 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
117
118 protected:
119 enum {
120 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
121 Base::PROVIDES_MEAN_POSITION,
123 };
124
126 VectorArray m_dSumP {VectorArray::Zero()};
127
128 public:
129 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer,meanPositionDer)
130 PONCA_FITTING_DECLARE_INIT
131 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
132
153 PONCA_MULTIARCH [[nodiscard]] VectorArray barycenterDerivatives() const
154 {
155 return ( m_dSumP - Base::barycenterLocal() * Base::m_dSumW ) / Base::getWeightSum();
156 }
157
158 }; //class MeanPositionDer
159
172 template<class DataPoint, class _NFilter, int DiffType, typename T>
173 class MeanNormalDer : public T {
174 PONCA_FITTING_DECLARE_DEFAULT_TYPES
175 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
176
177 protected:
178 enum {
179 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
180 Base::PROVIDES_MEAN_NORMAL,
182 };
183
185 VectorArray m_dSumN {VectorArray::Zero()};
186
187 public:
188
189 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer,meanNormalDer)
190 PONCA_FITTING_DECLARE_INIT
191 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
192
213
214 PONCA_MULTIARCH [[nodiscard]] VectorArray dMeanNormal() const
215 {
216 return ( m_dSumN - Base::meanNormalVector() * Base::m_dSumW ) / Base::getWeightSum();
217 }
218
219 }; //class MeanNormalDer
220
221#include "mean.hpp"
222
223} //namespace Ponca
Compute the derivatives of the input points mean normal.
Definition mean.h:173
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:175
MeanNormalDer< DataPoint, _NFilter, DiffType, T > & meanNormalDer()
Explicit conversion to MeanNormalDer , to access methods potentially hidden by heritage.
Definition mean.h:189
VectorArray m_dSumN
Derivatives of the input normals of the input points vectors.
Definition mean.h:185
VectorArray dMeanNormal() const
Compute the derivative of the mean normal vector of the input points.
Definition mean.h:214
@ PROVIDES_MEAN_NORMAL_DERIVATIVE
Provides derivative of the mean normal.
Definition mean.h:181
Compute the mean normal of the input points.
Definition mean.h:79
MeanNormal< DataPoint, _NFilter, T > & meanNormal()
Explicit conversion to MeanNormal , to access methods potentially hidden by heritage.
Definition mean.h:87
VectorType m_sumN
Sum of the normal vectors.
Definition mean.h:84
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:80
VectorType meanNormalVector() const
Mean of the normals of the input points.
Definition mean.h:95
Compute the derivatives of the input points barycenter.
Definition mean.h:114
@ PROVIDES_MEAN_POSITION_DERIVATIVE
Provides derivative of the mean position.
Definition mean.h:122
VectorArray m_dSumP
Derivatives of the input points vectors.
Definition mean.h:126
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:116
MeanPositionDer< DataPoint, _NFilter, DiffType, T > & meanPositionDer()
Explicit conversion to MeanPositionDer , to access methods potentially hidden by heritage.
Definition mean.h:129
VectorArray barycenterDerivatives() const
Compute derivatives of the barycenter (in local frame).
Definition mean.h:153
Compute the barycenter of the input points.
Definition mean.h:24
Scalar barycenterDistance() const
The distance between the barycenter and the basis center.
Definition mean.h:47
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition mean.h:25
VectorType barycenterLocal() const
Barycenter of the input points expressed in the local frame.
Definition mean.h:61
VectorType m_sumP
Sum of the input points vectors.
Definition mean.h:29
MeanPosition< DataPoint, _NFilter, T > & meanPosition()
Explicit conversion to MeanPosition , to access methods potentially hidden by heritage.
Definition mean.h:32
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:25
VectorType barycenter() const
Barycenter of the input points expressed in the global frame.
Definition mean.h:40
This Source Code Form is subject to the terms of the Mozilla Public License, v.