Ponca  4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
Point Cloud Analysis library
Loading...
Searching...
No Matches
gls.hpp
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
7template <class DataPoint, class _NFilter, typename T>
8 requires GLS_PARAM_REQUIREMENTS
10{
11 FIT_RESULT bResult = Base::finalize();
12
13 if (bResult != UNDEFINED)
14 {
15 m_fitness = Scalar(1.) - Base::prattNorm2();
16 }
17
18 return bResult;
19}
20
21template <class DataPoint, class _NFilter, int DiffType, typename T>
22 requires GLS_DER_REQUIREMENTS
24{
25 PONCA_MULTIARCH_STD_MATH(sqrt);
26
27 Scalar prattNorm2 = Base::prattNorm2();
28 Scalar prattNorm = sqrt(prattNorm2);
29 Scalar cfactor = Scalar(.5) / prattNorm;
30 ScalarArray dfield = Base::m_dUc;
31 // Recall that tau is the field function at the evaluation point, we thus must take care about
32 // its variation when differentiating in space:
33 if (Base::isSpaceDer())
34 dfield.template tail<DataPoint::Dim>() += Base::m_ul;
35
36 return (dfield * prattNorm - Base::m_uc * cfactor * Base::dprattNorm2()) / prattNorm2;
37}
38
39template <class DataPoint, class _NFilter, int DiffType, typename T>
40 requires GLS_DER_REQUIREMENTS
45
46template <class DataPoint, class _NFilter, int DiffType, typename T>
47 requires GLS_DER_REQUIREMENTS
49{
50 PONCA_MULTIARCH_STD_MATH(sqrt);
51
52 Scalar prattNorm2 = Base::prattNorm2();
53 Scalar prattNorm = sqrt(prattNorm2);
54 Scalar cfactor = Scalar(.5) / prattNorm;
55
56 return Scalar(2.) * (Base::m_dUq * prattNorm - Base::m_uq * cfactor * Base::dprattNorm2()) / prattNorm2;
57}
58
59template <class DataPoint, class _NFilter, int DiffType, typename T>
60 requires GLS_DER_REQUIREMENTS
62 T>::dtau_normalized() const
63{
64 return dtau();
65}
66
67template <class DataPoint, class _NFilter, int DiffType, typename T>
68 requires GLS_DER_REQUIREMENTS
70 T>::deta_normalized() const
71{
72 return Base::getNeighborFilter().evalScale() * deta();
73}
74
75template <class DataPoint, class _NFilter, int DiffType, typename T>
76 requires GLS_DER_REQUIREMENTS
78 T>::dkappa_normalized() const
79{
80 return dkappa() * Base::getNeighborFilter().evalScale() * Base::getNeighborFilter().evalScale();
81}
82
83template <class DataPoint, class _NFilter, int DiffType, typename T>
84 requires GLS_DER_REQUIREMENTS
87{
88 static_assert(bool(DiffType & FitScaleDer), "Scale derivatives are required to compute Geometric Variation");
89 Scalar dtau = dtau_normalized().col(0)(0);
90 Scalar deta = deta_normalized().col(0).norm();
91 Scalar dkappa = dkappa_normalized().col(0)(0);
92
93 return wtau * dtau * dtau + weta * deta * deta + wkappa * dkappa * dkappa;
94}
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
Differentiation of GLSParam.
Definition gls.h:117
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
Growing Least Squares reparametrization of the OrientedSphereFit.
Definition gls.h:46
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:47
DiffType
Flags defining which derivatives need to be computed.
Definition enums.h:34
@ FitScaleDer
Flag indicating a scale differentiation.
Definition enums.h:35
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
Definition enums.h:15
@ UNDEFINED
The fitting is undefined, you can't use it for valid results.
Definition enums.h:22