Ponca  4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
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 "../concepts.h"
11
12#define GLS_PARAM_REQUIREMENTS ProvidesAlgebraicSphere<T>
13#define GLS_DER_REQUIREMENTS ProvidesAlgebraicSphere<T>&& ProvidesImplicitPrimitiveDerivative<T>&& ProvidesGLSParam<T>
14
15namespace Ponca
16{
17
43 template <class DataPoint, class _NFilter, typename T>
44 requires GLS_PARAM_REQUIREMENTS
45 class GLSParam : public T
46 {
47 PONCA_FITTING_DECLARE_DEFAULT_TYPES
48 protected:
51 public:
52 PONCA_EXPLICIT_CAST_OPERATORS(GLSParam, glsParam)
53 PONCA_FITTING_DECLARE_FINALIZE
54
55 /**************************************************************************/
56 /* Use results */
57 /**************************************************************************/
59 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau() const
60 {
61 return Base::isNormalized() ? Base::m_uc : Base::m_uc / Base::prattNorm();
62 }
63
65 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta() const { return Base::primitiveGradient(); }
66
68 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa() const
69 {
70 return Scalar(2.) * (Base::isNormalized() ? Base::m_uq : Base::m_uq / Base::prattNorm());
71 }
72
74 PONCA_MULTIARCH [[nodiscard]] inline Scalar tau_normalized() const
75 {
76 return tau() / Base::getNeighborFilter().evalScale();
77 }
78
80 PONCA_MULTIARCH [[nodiscard]] inline VectorType eta_normalized() const { return eta(); }
81
83 PONCA_MULTIARCH [[nodiscard]] inline Scalar kappa_normalized() const
84 {
85 return kappa() * Base::getNeighborFilter().evalScale();
86 }
87
89 PONCA_MULTIARCH [[nodiscard]] inline Scalar fitness() const { return m_fitness; }
90
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
114 template <class DataPoint, class _NFilter, int DiffType, typename T>
115 requires GLS_DER_REQUIREMENTS
116 class GLSDer : public T
117 {
118 PONCA_FITTING_DECLARE_DEFAULT_TYPES
119 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
120 public:
121 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer, glsDer)
122 PONCA_EXPLICIT_CAST_OPERATORS_DER(GLSDer, geomVar)
123
124 PONCA_MULTIARCH inline ScalarArray dtau() const;
125 PONCA_MULTIARCH inline VectorArray deta() const;
126 PONCA_MULTIARCH inline ScalarArray dkappa() const;
128 PONCA_MULTIARCH inline ScalarArray dtau_normalized()
129 const;
130 PONCA_MULTIARCH inline VectorArray deta_normalized() const;
131 PONCA_MULTIARCH inline ScalarArray dkappa_normalized()
132 const;
149 PONCA_MULTIARCH inline Scalar geomVar(Scalar wtau = Scalar(1), Scalar weta = Scalar(1),
151 }; // class GLSScaleDer
152
153#include "gls.hpp"
154
155} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
Differentiation of GLSParam.
Definition gls.h:117
ScalarArray dkappa_normalized() const
Compute and return .
Definition gls.hpp:78
GLSDer< DataPoint, _NFilter, DiffType, T > & geomVar()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition gls.h:122
VectorArray deta_normalized() const
Compute and return .
Definition gls.hpp:70
GLSDer< DataPoint, _NFilter, DiffType, T > & glsDer()
Explicit conversion to GLSDer , to access methods potentially hidden by heritage.
Definition gls.h:121
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition gls.h:119
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
Definition gls.h:119
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:118
VectorArray deta() const
Compute and return derivatives.
Definition gls.hpp:41
ScalarArray dtau_normalized() const
Compute and return derivatives.
Definition gls.hpp:62
ScalarArray dtau() const
Compute and return derivatives.
Definition gls.hpp:23
ScalarArray dkappa() const
Compute and return derivatives.
Definition gls.hpp:48
Growing Least Squares reparametrization of the OrientedSphereFit.
Definition gls.h:46
VectorType eta() const
Compute and return .
Definition gls.h:65
GLSParam< DataPoint, _NFilter, T > & glsParam()
Explicit conversion to GLSParam , to access methods potentially hidden by heritage.
Definition gls.h:52
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:47
Scalar kappa() const
Compute and return .
Definition gls.h:68
Scalar tau_normalized() const
Compute and return .
Definition gls.h:74
VectorType eta_normalized() const
Compute and return .
Definition gls.h:80
Scalar tau() const
Compute and return .
Definition gls.h:59
Scalar kappa_normalized() const
Compute and return .
Definition gls.h:83
Scalar compareTo(const GLSParam< DataPoint, _NFilter, T > &_other, bool _useFitness=true) const
Compare current instance with other.
Definition gls.h:96
Scalar m_fitness
Save the fitness value to avoid side effect with Pratt normalization.
Definition gls.h:49
typename Base::VectorType VectorType
Alias to vector type.
Definition gls.h:47
Scalar fitness() const
Return the fitness, e.g.
Definition gls.h:89
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11