Ponca  40f245e28b920cbb763a1c6282156c87c626f24c
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 _WFunctor, 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::m_w.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
85 template<class DataPoint, class _WFunctor, typename T>
86 class MeanNormal : public T {
87 PONCA_FITTING_DECLARE_DEFAULT_TYPES
88
89 protected:
90 enum { PROVIDES_MEAN_NORMAL };
93 public:
94 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal,meanNormal)
95 PONCA_FITTING_DECLARE_INIT
96 PONCA_FITTING_DECLARE_ADDNEIGHBOR
97
102 PONCA_MULTIARCH inline VectorType meanNormalVector() const {
103 return (m_sumN / Base::getWeightSum());
104 }
105
106 }; //class MeanNormal
107
108 template<class DataPoint, class _WFunctor, int DiffType, typename T>
109 class MeanPositionDer : public T {
110 PONCA_FITTING_DECLARE_DEFAULT_TYPES
111 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
112
113 protected:
114 enum {
115 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
116 Base::PROVIDES_MEAN_POSITION,
118 };
119
121 VectorArray m_dSumP {VectorArray::Zero()};
122
123 public:
124 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer,meanPositionDer)
125 PONCA_FITTING_DECLARE_INIT
126 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
127
148 PONCA_MULTIARCH VectorArray barycenterDerivatives() const
149 {
150 return ( m_dSumP - Base::barycenterLocal() * Base::m_dSumW ) / Base::getWeightSum();
151 }
152
153 }; //class MeanPositionDer
154
155 template<class DataPoint, class _WFunctor, int DiffType, typename T>
156 class MeanNormalDer : public T {
157 PONCA_FITTING_DECLARE_DEFAULT_TYPES
158 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
159
160 protected:
161 enum {
162 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
163 Base::PROVIDES_MEAN_NORMAL,
165 };
166
168 VectorArray m_dSumN {VectorArray::Zero()};
169
170 public:
171
172 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer,meanNormalDer)
173 PONCA_FITTING_DECLARE_INIT
174 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
175
196
197 PONCA_MULTIARCH VectorArray dMeanNormal() const
198 {
199 return ( m_dSumN - Base::meanNormalVector() * Base::m_dSumW ) / Base::getWeightSum();
200 }
201
202 }; //class MeanNormalDer
203
204#include "mean.hpp"
205
206} //namespace Ponca
MeanNormalDer< DataPoint, _WFunctor, DiffType, T > & meanNormalDer()
Explicit conversion to MeanNormalDer , to access methods potentially hidden by heritage.
Definition mean.h:172
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:158
VectorArray dMeanNormal() const
Compute the derivative of the mean normal vector of the input points.
Definition mean.h:197
VectorArray m_dSumN
Derivatives of the input normals of the input points vectors.
Definition mean.h:168
@ PROVIDES_MEAN_NORMAL_DERIVATIVE
Provides derivative of the mean normal.
Definition mean.h:164
Compute the barycenter of the input points + their normals.
Definition mean.h:86
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:87
VectorType m_sumN
Sum of the normal vectors.
Definition mean.h:91
VectorType meanNormalVector() const
Mean of the normals of the input points.
Definition mean.h:102
MeanNormal< DataPoint, _WFunctor, T > & meanNormal()
Explicit conversion to MeanNormal , to access methods potentially hidden by heritage.
Definition mean.h:94
VectorArray m_dSumP
Derivatives of the input points vectors.
Definition mean.h:121
@ PROVIDES_MEAN_POSITION_DERIVATIVE
Provides derivative of the mean position.
Definition mean.h:117
MeanPositionDer< DataPoint, _WFunctor, DiffType, T > & meanPositionDer()
Explicit conversion to MeanPositionDer , to access methods potentially hidden by heritage.
Definition mean.h:124
VectorArray barycenterDerivatives() const
Compute derivatives of the barycenter (in local frame).
Definition mean.h:148
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition mean.h:111
Compute the barycenter of the input points.
Definition mean.h:24
VectorType barycenter() const
Barycenter of the input points expressed in the global frame.
Definition mean.h:40
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
Scalar barycenterDistance() const
The distance between the barycenter and the basis center.
Definition mean.h:47
MeanPosition< DataPoint, _WFunctor, T > & meanPosition()
Explicit conversion to MeanPosition , to access methods potentially hidden by heritage.
Definition mean.h:32
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition mean.h:25
typename Base::VectorType VectorType
Alias to vector type.
Definition mean.h:25
This Source Code Form is subject to the terms of the Mozilla Public License, v.