Ponca  aa50bfdf187919869239c5b44b748842569114c1
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 _WFunctor, typename T>
8inline FIT_RESULT
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 _WFunctor, int DiffType, typename T>
22typename GLSDer <DataPoint, _WFunctor, DiffType, T>::ScalarArray
23GLSDer <DataPoint, _WFunctor, DiffType, T>::dtau() const
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(this->isSpaceDer())
34 dfield.template tail<DataPoint::Dim>() += Base::m_ul;
35
36 return (dfield * prattNorm - Base::m_uc * cfactor * Base::dprattNorm2()) / prattNorm2;
37}
38
39
40template < class DataPoint, class _WFunctor, int DiffType, typename T>
41typename GLSDer <DataPoint, _WFunctor, DiffType, T>::VectorArray
42GLSDer <DataPoint, _WFunctor, DiffType, T>::deta() const
43{
44 return Base::dNormal();
45}
46
47
48template < class DataPoint, class _WFunctor, int DiffType, typename T>
49typename GLSDer <DataPoint, _WFunctor, DiffType, T>::ScalarArray
50GLSDer <DataPoint, _WFunctor, DiffType, T>::dkappa() const
51{
52 PONCA_MULTIARCH_STD_MATH(sqrt);
53
54 Scalar prattNorm2 = Base::prattNorm2();
55 Scalar prattNorm = sqrt(prattNorm2);
56 Scalar cfactor = Scalar(.5) / prattNorm;
57
58 return Scalar(2.) * (Base::m_dUq * prattNorm - Base::m_uq * cfactor * Base::dprattNorm2()) / prattNorm2;
59}
60
61
62template < class DataPoint, class _WFunctor, int DiffType, typename T>
63typename GLSDer <DataPoint, _WFunctor, DiffType, T>::ScalarArray
64GLSDer <DataPoint, _WFunctor, DiffType, T>::dtau_normalized() const
65{
66 return dtau();
67}
68
69
70template < class DataPoint, class _WFunctor, int DiffType, typename T>
71typename GLSDer <DataPoint, _WFunctor, DiffType, T>::VectorArray
72GLSDer <DataPoint, _WFunctor, DiffType, T>::deta_normalized() const
73{
74 return Base::m_w.evalScale() * deta();
75}
76
77
78template < class DataPoint, class _WFunctor, int DiffType, typename T>
79typename GLSDer <DataPoint, _WFunctor, DiffType, T>::ScalarArray
80GLSDer <DataPoint, _WFunctor, DiffType, T>::dkappa_normalized() const
81{
82 return dkappa() * Base::m_w.evalScale() * Base::m_w.evalScale();
83}
84
85
86
87
88template < class DataPoint, class _WFunctor, int DiffType, typename T>
89typename GLSDer <DataPoint, _WFunctor, DiffType, T>::Scalar
90GLSDer <DataPoint, _WFunctor, DiffType, T>::geomVar( Scalar wtau,
91 Scalar weta,
92 Scalar wkappa ) const
93{
94 static_assert( bool(DiffType & FitScaleDer), "Scale derivatives are required to compute Geometric Variation" );
95 Scalar dtau = dtau_normalized().col(0)(0);
96 Scalar deta = deta_normalized().col(0).norm();
97 Scalar dkappa = dkappa_normalized().col(0)(0);
98
99 return wtau*dtau*dtau + weta*deta*deta + wkappa*dkappa*dkappa;
100}
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 reparemetrization of the OrientedSphereFit.
Definition: gls.h:42
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition: gls.h:43
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