Ponca  aa50bfdf187919869239c5b44b748842569114c1
Point Cloud Analysis library
Loading...
Searching...
No Matches
gls.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 "./curvature.h"
11
12namespace Ponca
13{
14
40template < class DataPoint, class _WFunctor, typename T>
41class GLSParam : public T
42{
43 PONCA_FITTING_DECLARE_DEFAULT_TYPES
44
46protected:
47 enum
48 {
49 Check = Base::PROVIDES_ALGEBRAIC_SPHERE,
50 PROVIDES_GLS_PARAMETRIZATION
51 };
53
54protected:
57public:
58 PONCA_EXPLICIT_CAST_OPERATORS(GLSParam,glsParam)
59 PONCA_FITTING_DECLARE_FINALIZE
60
61 /**************************************************************************/
62 /* Use results */
63 /**************************************************************************/
65 PONCA_MULTIARCH inline Scalar tau() const
66 {
67 return Base::isNormalized() ? Base::m_uc : Base::m_uc / Base::prattNorm();
68 }
69
71 PONCA_MULTIARCH inline VectorType eta() const { return Base::primitiveGradient(); }
72
74 PONCA_MULTIARCH inline Scalar kappa() const
75 {
76 return Scalar(2.) * (Base::isNormalized() ? Base::m_uq : Base::m_uq / Base::prattNorm());
77 }
78
80 PONCA_MULTIARCH inline Scalar tau_normalized() const { return tau() / Base::m_w.evalScale(); }
81
83 PONCA_MULTIARCH inline VectorType eta_normalized() const { return eta(); }
84
86 PONCA_MULTIARCH inline Scalar kappa_normalized() const { return kappa() * Base::m_w.evalScale(); }
87
89 PONCA_MULTIARCH inline Scalar fitness() const { return m_fitness; }
90
96 PONCA_MULTIARCH inline Scalar compareTo (const GLSParam<DataPoint, _WFunctor, T>& _other,
97 bool _useFitness = true) const
98 {
99 Scalar nTau = this->tau_normalized() - _other.tau_normalized();
100 Scalar nKappa = this->kappa_normalized() - _other.kappa_normalized();
101 Scalar nFitness = _useFitness ? this->fitness() - _other.fitness() : Scalar(0.);
102
103 return nTau * nTau + nKappa * nKappa + nFitness * nFitness;
104 }
105
106}; //class GLSParam
107
108
115template < class DataPoint, class _WFunctor, int DiffType, typename T>
116class GLSDer : public T
117{
118PONCA_FITTING_DECLARE_DEFAULT_TYPES
119PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
120
121protected:
122 enum
123 {
124 Check = Base::PROVIDES_GLS_PARAMETRIZATION &
125 Base::PROVIDES_PRIMITIVE_DERIVATIVE &
126 Base::PROVIDES_ALGEBRAIC_SPHERE_DERIVATIVE,
127 PROVIDES_GLS_DERIVATIVE,
128 PROVIDES_GLS_GEOM_VAR
129 };
130
131public:
132 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer,glsDer)
133
134 PONCA_MULTIARCH inline ScalarArray dtau() const;
135 PONCA_MULTIARCH inline VectorArray deta() const;
136 PONCA_MULTIARCH inline ScalarArray dkappa() const;
138 PONCA_MULTIARCH inline ScalarArray dtau_normalized() const;
139 PONCA_MULTIARCH inline VectorArray deta_normalized() const;
140 PONCA_MULTIARCH inline ScalarArray dkappa_normalized() const;
157 PONCA_MULTIARCH inline Scalar geomVar(Scalar wtau = Scalar(1),
158 Scalar weta = Scalar(1),
159 Scalar wkappa = Scalar(1)) const;
160}; //class GLSScaleDer
161
162
163#include "gls.hpp"
164
165} //namespace Ponca
Differentiation of GLSParam.
Definition: gls.h:117
VectorArray deta() const
Compute and return derivatives.
Definition: gls.hpp:42
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
Definition: gls.h:119
Scalar geomVar(Scalar wtau=Scalar(1), Scalar weta=Scalar(1), Scalar wkappa=Scalar(1)) const
The Geometric Variation is computed as the weighted sum of the GLS scale-invariant partial derivative...
Definition: gls.hpp:90
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition: gls.h:118
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition: gls.h:119
ScalarArray dtau() const
Compute and return derivatives.
Definition: gls.hpp:23
ScalarArray dkappa() const
Compute and return derivatives.
Definition: gls.hpp:50
GLSDer< DataPoint, _WFunctor, DiffType, T > & glsDer()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition: gls.h:132
VectorArray deta_normalized() const
Compute and return .
Definition: gls.hpp:72
ScalarArray dkappa_normalized() const
Compute and return .
Definition: gls.hpp:80
ScalarArray dtau_normalized() const
Compute and return derivatives.
Definition: gls.hpp:64
Growing Least Squares reparemetrization of the OrientedSphereFit.
Definition: gls.h:42
GLSParam< DataPoint, _WFunctor, T > & glsParam()
Explicit conversion to GLSParam , to access methods potentially hidden by heritage.
Definition: gls.h:58
Scalar compareTo(const GLSParam< DataPoint, _WFunctor, T > &_other, bool _useFitness=true) const
Compare current instance with other.
Definition: gls.h:96
Scalar tau_normalized() const
Compute and return .
Definition: gls.h:80
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition: gls.h:43
VectorType eta() const
Compute and return .
Definition: gls.h:71
VectorType eta_normalized() const
Compute and return .
Definition: gls.h:83
Scalar fitness() const
Return the fitness, e.g.
Definition: gls.h:89
Scalar tau() const
Compute and return .
Definition: gls.h:65
Scalar kappa_normalized() const
Compute and return .
Definition: gls.h:86
Scalar m_fitness
[Requirements]
Definition: gls.h:55
typename Base::VectorType VectorType
Alias to vector type.
Definition: gls.h:43
Scalar kappa() const
Compute and return .
Definition: gls.h:74
This Source Code Form is subject to the terms of the Mozilla Public License, v.