1#include <Eigen/Eigenvalues>
7 template <
class DataPo
int,
class _NFilter,
typename T>
8 typename FundamentalFormWeingartenEstimator<DataPoint, _NFilter, T>::Matrix2 FundamentalFormWeingartenEstimator<
9 DataPoint, _NFilter, T>::firstFundamentalForm()
const
12 firstFundamentalForm(first);
16 template <
class DataPo
int,
class _NFilter,
typename T>
17 template <
typename Matrix2Derived>
20 Base::firstFundamentalFormComponents(first(0, 0), first(1, 0), first(1, 1));
21 first(0, 1) = first(1, 0);
24 template <
class DataPo
int,
class _NFilter,
typename T>
26 DataPoint, _NFilter, T>::secondFundamentalForm()
const
29 secondFundamentalForm(second);
33 template <
class DataPo
int,
class _NFilter,
typename T>
34 template <
typename Matrix2Derived>
37 Base::secondFundamentalFormComponents(second(0, 0), second(1, 0), second(1, 1));
38 second(0, 1) = second(1, 0);
41 template <
class DataPo
int,
class _NFilter,
typename T>
43 DataPoint, _NFilter, T>::weingartenMap()
const
50 template <
class DataPo
int,
class _NFilter,
typename T>
51 template <
typename Matrix2Derived>
54 w = firstFundamentalForm().inverse() * secondFundamentalForm();
57 template <
class DataPo
int,
class _NFilter,
typename T>
59 DataPoint, _NFilter, T>::kMean()
const
62 Base::firstFundamentalFormComponents(E, F, G);
63 Base::secondFundamentalFormComponents(L, M, N);
64 return (G * L -
Scalar(2) * F * M + E * N) / (
Scalar(2) * (E * G - F * F));
67 template <
class DataPo
int,
class _NFilter,
typename T>
69 DataPoint, _NFilter, T>::GaussianCurvature()
const
72 Base::firstFundamentalFormComponents(E, F, G);
73 Base::secondFundamentalFormComponents(L, M, N);
74 return (L * N - M * M) / (E * G - F * F);
78 template <
class DataPo
int,
class _NFilter,
int DiffType,
typename T>
79 typename NormalDerivativeWeingartenEstimator<DataPoint, _NFilter, DiffType, T>::Matrix2
87 template <
class DataPo
int,
class _NFilter,
int DiffType,
typename T>
91 PONCA_MULTIARCH_STD_MATH(abs);
92 PONCA_MULTIARCH_STD_MATH(sqrt);
94 using Index =
typename VectorType::Index;
100 Index i0 = Index(-1), i1 = Index(-1), i2 = Index(-1);
102 MatrixType dN = Base::dNormal().template middleCols<DataPoint::Dim>(Base::isScaleDer() ? 1 : 0);
105 n.array().abs().minCoeff(&i0);
109 m_tangentBasis.col(0) = n;
111 m_tangentBasis.col(1)[i0] = 0;
112 m_tangentBasis.col(1)[i1] = n[i2];
113 m_tangentBasis.col(1)[i2] = -n[i1];
115 m_tangentBasis.col(1).normalize();
116 m_tangentBasis.col(2) = m_tangentBasis.col(1).cross(n);
118 return Base::m_eCurrentState;
121 template <
class DataPo
int,
class _NFilter,
int DiffType,
typename T>
122 template <
typename Matrix2Derived>
125 PONCA_MULTIARCH_STD_MATH(abs);
126 PONCA_MULTIARCH_STD_MATH(sqrt);
128 using Index =
typename VectorType::Index;
129 using Matrix32 = Eigen::Matrix<Scalar, 3, 2>;
132 MatrixType dN = Base::dNormal().template middleCols<DataPoint::Dim>(Base::isScaleDer() ? 1 : 0);
135 auto B = m_tangentBasis.template rightCols<2>();
139 W = B.transpose() * dN * B;
155 W(0, 1) = W(1, 0) = (W(0, 1) + W(1, 0)) /
Scalar(2);
158 template <
class DataPo
int,
class _NFilter,
int DiffType,
typename T>
161 const VectorType& _q,
bool _isPositionVector)
const
163 return m_tangentBasis.normalized().transpose() *
164 Base::getNeighborFilter().convertToLocalBasis(_q, _isPositionVector);
167 template <
class DataPo
int,
class _NFilter,
int DiffType,
typename T>
170 const VectorType& _lq,
bool _isPositionVector)
const
172 return Base::getNeighborFilter().convertToGlobalBasis(m_tangentBasis.normalized().transpose().inverse() * _lq,
179 template <
class DataPo
int,
class _NFilter,
typename T>
183 if (Base::finalize() !=
STABLE)
184 return Base::m_eCurrentState;
187 Base::weingartenMap(w);
190 Eigen::SelfAdjointEigenSolver<Matrix2> solver;
191 solver.computeDirect(w);
193 Scalar kmin = solver.eigenvalues().x();
194 Scalar kmax = solver.eigenvalues().y();
199 vmin.template bottomRows<2>() = solver.eigenvectors().col(0);
200 vmax.template bottomRows<2>() = solver.eigenvectors().col(1);
202 vmin = Base::tangentPlaneToWorld(vmin,
false);
203 vmax = Base::tangentPlaneToWorld(vmax,
false);
205 Base::setCurvatureValues(kmin, kmax, vmin, vmax);
207 return Base::m_eCurrentState;
typename Base::VectorType VectorType
Alias to vector type.
VectorType tangentPlaneToWorld(const VectorType &_q, bool _isPositionVector=true) const
Transform a point from the tangent plane [h, u, v]^T to ambient space.
VectorType worldToTangentPlane(const VectorType &_q, bool _isPositionVector=true) const
Express a point in ambient space relatively to the tangent plane.
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Matrix2 weingartenMap() const
Returns the Weingarten Map.
typename DataPoint::Scalar Scalar
Alias to scalar type.
FIT_RESULT finalize()
Finalize the procedure.
typename Base::VectorType VectorType
Alias to vector type.
FIT_RESULT finalize()
Finalize the procedure.
typename DataPoint::Scalar Scalar
Alias to scalar type.
This Source Code Form is subject to the terms of the Mozilla Public License, v.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
@ STABLE
The fitting is stable and ready to use.