Ponca  aa50bfdf187919869239c5b44b748842569114c1
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
44 protected:
54 PONCA_MULTIARCH inline VectorType barycenterLocal() const {
55 return (m_sumP / Base::getWeightSum());
56 }
57
58 }; //class MeanPosition
59
78 template<class DataPoint, class _WFunctor, typename T>
79 class MeanNormal : public T {
80 PONCA_FITTING_DECLARE_DEFAULT_TYPES
81
82 protected:
83 enum { PROVIDES_MEAN_NORMAL };
86 public:
87 PONCA_EXPLICIT_CAST_OPERATORS(MeanNormal,meanNormal)
88 PONCA_FITTING_DECLARE_INIT
89 PONCA_FITTING_DECLARE_ADDNEIGHBOR
90
95 PONCA_MULTIARCH inline VectorType meanNormalVector() const {
96 return (m_sumN / Base::getWeightSum());
97 }
98
99 }; //class MeanNormal
100
101 template<class DataPoint, class _WFunctor, int DiffType, typename T>
102 class MeanPositionDer : public T {
103 PONCA_FITTING_DECLARE_DEFAULT_TYPES
104 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
105
106 protected:
107 enum {
108 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
109 Base::PROVIDES_MEAN_POSITION,
111 };
112
114 VectorArray m_dSumP {VectorArray::Zero()};
115
116 public:
117 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanPositionDer,meanPositionDer)
118 PONCA_FITTING_DECLARE_INIT
119 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
120
141 PONCA_MULTIARCH VectorArray barycenterDerivatives() const
142 {
143 return ( m_dSumP - Base::barycenterLocal() * Base::m_dSumW ) / Base::getWeightSum();
144 }
145
146 }; //class MeanPositionDer
147
148 template<class DataPoint, class _WFunctor, int DiffType, typename T>
149 class MeanNormalDer : public T {
150 PONCA_FITTING_DECLARE_DEFAULT_TYPES
151 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
152
153 protected:
154 enum {
155 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
156 Base::PROVIDES_MEAN_NORMAL,
158 };
159
161 VectorArray m_dSumN {VectorArray::Zero()};
162
163 public:
164
165 PONCA_EXPLICIT_CAST_OPERATORS_DER(MeanNormalDer,meanNormalDer)
166 PONCA_FITTING_DECLARE_INIT
167 PONCA_FITTING_DECLARE_ADDNEIGHBOR_DER
168
189
190 PONCA_MULTIARCH VectorArray dMeanNormal() const
191 {
192 return ( m_dSumN - Base::meanNormalVector() * Base::m_dSumW ) / Base::getWeightSum();
193 }
194
195 }; //class MeanNormalDer
196
197#include "mean.hpp"
198
199} //namespace Ponca
MeanNormalDer< DataPoint, _WFunctor, DiffType, T > & meanNormalDer()
Explicit conversion to MeanNormalDer , to access methods potentially hidden by heritage.
Definition: mean.h:165
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition: mean.h:151
VectorArray dMeanNormal() const
Compute the derivative of the mean normal vector of the input points.
Definition: mean.h:190
VectorArray m_dSumN
Derivatives of the input normals of the input points vectors.
Definition: mean.h:161
@ PROVIDES_MEAN_NORMAL_DERIVATIVE
Provides derivative of the mean normal.
Definition: mean.h:157
Compute the barycenter of the input points + their normals.
Definition: mean.h:79
typename Base::VectorType VectorType
Alias to vector type.
Definition: mean.h:80
VectorType m_sumN
Sum of the normal vectors.
Definition: mean.h:84
VectorType meanNormalVector() const
Mean of the normals of the input points.
Definition: mean.h:95
MeanNormal< DataPoint, _WFunctor, T > & meanNormal()
Explicit conversion to MeanNormal , to access methods potentially hidden by heritage.
Definition: mean.h:87
VectorArray m_dSumP
Derivatives of the input points vectors.
Definition: mean.h:114
@ PROVIDES_MEAN_POSITION_DERIVATIVE
Provides derivative of the mean position.
Definition: mean.h:110
MeanPositionDer< DataPoint, _WFunctor, DiffType, T > & meanPositionDer()
Explicit conversion to MeanPositionDer , to access methods potentially hidden by heritage.
Definition: mean.h:117
VectorArray barycenterDerivatives() const
Compute derivatives of the barycenter (in local frame).
Definition: mean.h:141
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition: mean.h:104
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:54
VectorType m_sumP
Sum of the input points vectors.
Definition: mean.h:29
MeanPosition< DataPoint, _WFunctor, 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
This Source Code Form is subject to the terms of the Mozilla Public License, v.