Ponca  bab7704293a2c36e5bed9dea40def7ba839bfe08
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>
9{
10 FIT_RESULT bResult = Base::finalize();
11
12 if (bResult != UNDEFINED)
13 {
14 m_fitness = Scalar(1.) - Base::prattNorm2();
15 }
16
17 return bResult;
18}
19
20template <class DataPoint, class _NFilter, int DiffType, typename T>
22{
23 PONCA_MULTIARCH_STD_MATH(sqrt);
24
25 Scalar prattNorm2 = Base::prattNorm2();
26 Scalar prattNorm = sqrt(prattNorm2);
27 Scalar cfactor = Scalar(.5) / prattNorm;
28 ScalarArray dfield = Base::m_dUc;
29 // Recall that tau is the field function at the evaluation point, we thus must take care about
30 // its variation when differentiating in space:
31 if (Base::isSpaceDer())
32 dfield.template tail<DataPoint::Dim>() += Base::m_ul;
33
34 return (dfield * prattNorm - Base::m_uc * cfactor * Base::dprattNorm2()) / prattNorm2;
35}
36
37template <class DataPoint, class _NFilter, int DiffType, typename T>
42
43template <class DataPoint, class _NFilter, int DiffType, typename T>
45{
46 PONCA_MULTIARCH_STD_MATH(sqrt);
47
48 Scalar prattNorm2 = Base::prattNorm2();
49 Scalar prattNorm = sqrt(prattNorm2);
50 Scalar cfactor = Scalar(.5) / prattNorm;
51
52 return Scalar(2.) * (Base::m_dUq * prattNorm - Base::m_uq * cfactor * Base::dprattNorm2()) / prattNorm2;
53}
54
55template <class DataPoint, class _NFilter, int DiffType, typename T>
57 T>::dtau_normalized() const
58{
59 return dtau();
60}
61
62template <class DataPoint, class _NFilter, int DiffType, typename T>
64 T>::deta_normalized() const
65{
66 return Base::getNeighborFilter().evalScale() * deta();
67}
68
69template <class DataPoint, class _NFilter, int DiffType, typename T>
71 T>::dkappa_normalized() const
72{
73 return dkappa() * Base::getNeighborFilter().evalScale() * Base::getNeighborFilter().evalScale();
74}
75
76template <class DataPoint, class _NFilter, int DiffType, typename T>
78 Scalar wtau, Scalar weta, Scalar wkappa) const
79{
80 static_assert(bool(DiffType & FitScaleDer), "Scale derivatives are required to compute Geometric Variation");
81 Scalar dtau = dtau_normalized().col(0)(0);
82 Scalar deta = deta_normalized().col(0).norm();
83 Scalar dkappa = dkappa_normalized().col(0)(0);
84
85 return wtau * dtau * dtau + weta * deta * deta + wkappa * dkappa * dkappa;
86}
Differentiation of GLSParam.
Definition gls.h:122
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Definition gls.h:124
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
Definition gls.h:124
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition gls.h:123
Growing Least Squares reparametrization 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