Ponca  7abd0fd82719106ad460aa0f2070dffbe375d727
Point Cloud Analysis library
Loading...
Searching...
No Matches
orientedSphereFit.h
1/*
2This Source Code Form is subject to the terms of the Mozilla Public
3License, v. 2.0. If a copy of the MPL was not distributed with this
4file, You can obtain one at http://mozilla.org/MPL/2.0/.
5*/
6
7#pragma once
8#include "../../defines.h"
9#include "../concepts.h"
10
11#include "../primitive/algebraicSphere.h" // used to define OrientedSphereFit
12#include "../tools/mean.h" // used to define OrientedSphereFit
13
14#define ORIENTED_SPHERE_FIT_REQUIREMENTS \
15 ProvidesAlgebraicSphere<T>&& ProvidesMeanPosition<T>&& ProvidesMeanNormal<T>&& ProvidesNormal<DataPoint>
16#define ORIENTED_SPHERE_DER_REQUIREMENTS \
17 ProvidesBasketDiffUnitBase<T>&& ProvidesAlgebraicSphere<T>&& ProvidesMeanPositionDerivative<T>
18
19namespace Ponca
20{
21
31 template <class DataPoint, class _NFilter, typename T>
32 requires ORIENTED_SPHERE_FIT_REQUIREMENTS
33 class OrientedSphereFitImpl : public T
34 {
35 PONCA_FITTING_DECLARE_DEFAULT_TYPES
36
37 protected:
38 // computation data
41 m_nume{0},
42 m_deno{0};
44 public:
45 PONCA_EXPLICIT_CAST_OPERATORS(OrientedSphereFitImpl, orientedSphereFit)
46 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
47 PONCA_FITTING_IS_SIGNED(true)
48 }; // class OrientedSphereFitImpl
49
52 template <class DataPoint, class _NFilter, typename T>
54 DataPoint, _NFilter,
57
61 template <class DataPoint, class _NFilter, int DiffType, typename T>
62 requires ORIENTED_SPHERE_DER_REQUIREMENTS
63 class OrientedSphereDerImpl : public T
64 {
65 PONCA_FITTING_DECLARE_DEFAULT_TYPES
66 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
67
68 protected:
69 // computation data
70 VectorArray m_dSumN{VectorArray::Zero()};
71 ScalarArray m_dSumDotPN{ScalarArray::Zero()},
74 ScalarArray::Zero()},
75 m_dNume{ScalarArray::Zero()},
76 m_dDeno{ScalarArray::Zero()};
78 public:
79 // results
80 ScalarArray m_dUc{ScalarArray::Zero()},
81 m_dUq{ScalarArray::Zero()};
82 VectorArray m_dUl{VectorArray::Zero()};
84 public:
85 PONCA_EXPLICIT_CAST_OPERATORS_DER(OrientedSphereDerImpl, orientedSphereDer)
86 PONCA_EXPLICIT_CAST_OPERATORS_DER(OrientedSphereDerImpl, algebraicSphereDer)
87 PONCA_EXPLICIT_CAST_OPERATORS_DER(OrientedSphereDerImpl, implicitPrimitiveDer)
88
89 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
90
92 PONCA_MULTIARCH [[nodiscard]] inline ScalarArray dPotential() const;
93
95 PONCA_MULTIARCH [[nodiscard]] inline VectorArray dNormal() const;
96
98 PONCA_MULTIARCH [[nodiscard]] inline ScalarArray dprattNorm2() const
99 {
100 return Scalar(2.) * Base::m_ul.transpose() * m_dUl - Scalar(4.) * Base::m_uq * m_dUc -
101 Scalar(4.) * Base::m_uc * m_dUq;
102 }
103
105 PONCA_MULTIARCH [[nodiscard]] inline Scalar dprattNorm2(unsigned int _d) const
106 {
107 return Scalar(2.) * m_dUl.col(_d).dot(Base::m_ul) - Scalar(4.) * m_dUc.col(_d)[0] * Base::m_uq -
108 Scalar(4.) * m_dUq.col(_d)[0] * Base::m_uc;
109 }
110
112 PONCA_MULTIARCH [[nodiscard]] inline Scalar dprattNorm(unsigned int _d) const
113 {
114 PONCA_MULTIARCH_STD_MATH(sqrt);
115 return sqrt(dprattNorm2(_d));
116 }
117
119 PONCA_MULTIARCH [[nodiscard]] inline ScalarArray dprattNorm() const
120 {
121 PONCA_MULTIARCH_STD_MATH(sqrt);
122 return dprattNorm2().array().sqrt();
123 }
125
129 PONCA_MULTIARCH [[nodiscard]] inline bool applyPrattNorm();
130
131 }; // class OrientedSphereDerImpl
132
134 template <class DataPoint, class _NFilter, int DiffType, typename T>
137
138#include "orientedSphereFit.hpp"
139
140} // namespace Ponca
Compute the barycenter of the input points.
Definition mean.h:29
[OrientedSphereFit Definition]
ScalarArray m_dSumDotPP
Sum of the squared relative positions with weight derivatives.
OrientedSphereDerImpl< DataPoint, _NFilter, DiffType, T > & implicitPrimitiveDer()
Explicit conversion to OrientedSphereDerImpl , to access methods potentially hidden by heritage.
ScalarArray dPotential() const
Returns the derivatives of the scalar field at the evaluation point.
ScalarArray m_dUc
Derivatives of the hyper-sphere constant term
ScalarArray m_dSumDotPN
Sum of the dot product between relative positions and normals with weight derivatives.
VectorArray m_dSumN
Sum of the normal vectors with weight derivatives.
ScalarArray m_dNume
Derivatives of the numerator of the quadratic parameter
VectorArray m_dUl
Derivatives of the hyper-sphere linear term
Scalar dprattNorm2(unsigned int _d) const
compute the square of the Pratt norm derivative for dimension _d
ScalarArray m_dUq
Derivatives of the hyper-sphere quadratic term.
ScalarArray dprattNorm2() const
compute the square of the Pratt norm derivative
ScalarArray dprattNorm() const
compute the Pratt norm derivative
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
VectorArray dNormal() const
Returns the derivatives of the primitive normal.
typename DataPoint::Scalar Scalar
Alias to scalar type.
bool applyPrattNorm()
Normalize the scalar field by the Pratt norm.
OrientedSphereDerImpl< DataPoint, _NFilter, DiffType, T > & algebraicSphereDer()
Explicit conversion to OrientedSphereDerImpl , to access methods potentially hidden by heritage.
OrientedSphereDerImpl< DataPoint, _NFilter, DiffType, T > & orientedSphereDer()
Explicit conversion to OrientedSphereDerImpl , to access methods potentially hidden by heritage.
ScalarArray m_dDeno
Derivatives of the denominator of the quadratic parameter.
Scalar dprattNorm(unsigned int _d) const
compute the Pratt norm derivative for the dimension _d
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
Algebraic Sphere fitting procedure on oriented point sets.
Scalar m_sumDotPP
Sum of the squared relative positions.
OrientedSphereFitImpl< DataPoint, _NFilter, T > & orientedSphereFit()
Explicit conversion to OrientedSphereFitImpl , to access methods potentially hidden by heritage.
typename DataPoint::Scalar Scalar
Alias to scalar type.
Scalar m_sumDotPN
Sum of the dot product between relative positions and normals.
Scalar m_nume
Numerator of the quadratic parameter (excluding the 0.5 coefficient)
Scalar m_deno
Denominator of the quadratic parameter (excluding the 0.5 coefficient)
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11