7template <
class DataPo
int,
class _NFilter,
typename T>
8 requires SPHERE_FIT_REQUIREMENTS
9void SphereFitImpl<DataPoint, _NFilter, T>::init()
15template <
class DataPo
int,
class _NFilter,
typename T>
16 requires SPHERE_FIT_REQUIREMENTS
18 const DataPoint& attributes)
20 Base::addLocalNeighbor(w, localQ, attributes);
24 a.template segment<DataPoint::Dim>(1) = localQ;
25 a(DataPoint::Dim + 1) = localQ.squaredNorm();
27 a << 1, localQ, localQ.squaredNorm();
29 m_matA += w * a * a.transpose();
32template <
class DataPo
int,
class _NFilter,
typename T>
33 requires SPHERE_FIT_REQUIREMENTS
37 if (Base::finalize() != STABLE)
38 return Base::m_eCurrentState;
39 if (Base::getNumNeighbors() < DataPoint::Dim)
41 if (Base::algebraicSphere().isValid())
44 Base::m_eCurrentState = Base::getNumNeighbors() < 2 * DataPoint::Dim ?
UNSTABLE :
STABLE;
48 matC.template topRightCorner<1, 1>() << -2;
49 matC.template bottomLeftCorner<1, 1>() << -2;
50 matC.template topLeftCorner<1, 1>() << 0;
51 matC.template bottomRightCorner<1, 1>() << 0;
54 invCpratt.setIdentity();
55 invCpratt.template topRightCorner<1, 1>() << -0.5;
56 invCpratt.template bottomLeftCorner<1, 1>() << -0.5;
57 invCpratt.template topLeftCorner<1, 1>() << 0;
58 invCpratt.template bottomRightCorner<1, 1>() << 0;
67 m_solver.computeDirect(invCpratt * m_matA);
69 m_solver.compute(invCpratt * m_matA);
71 VectorA eivals = m_solver.eigenvalues().real();
73 for (
int i = 0; i < DataPoint::Dim + 2; ++i)
75 Scalar ev = eivals(i);
76 if ((ev > 0) && (minId == -1 || ev < eivals(minId)))
81 VectorA vecU = m_solver.eigenvectors().col(minId).real();
82 Base::m_uq = vecU[1 + DataPoint::Dim];
83 Base::m_ul = vecU.template segment<DataPoint::Dim>(1);
86 Base::m_isNormalized =
false;
88 return Base::m_eCurrentState;
Algebraic Sphere fitting procedure on point set without normals.
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename Base::VectorType VectorType
Alias to vector type.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
@ UNDEFINED
The fitting is undefined, you can't use it for valid results.
@ CONFLICT_ERROR_FOUND
Multiple classes of the fitting procedure initialize the primitive.
@ STABLE
The fitting is stable and ready to use.
@ UNSTABLE
The fitting is ready to use but it is considered as unstable (if the number of neighbors is low for e...