7template <
class DataPo
int,
class _NFilter,
typename T>
8 requires ALGEBRAIC_SPHERE_REQUIREMENTS
9typename AlgebraicSphere<DataPoint, _NFilter, T>::VectorType
10AlgebraicSphere<DataPoint, _NFilter, T>::project(
const VectorType& _q)
const
12 PONCA_MULTIARCH_STD_MATH(sqrt);
15 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
19 Scalar sqnorm = m_ul.squaredNorm();
20 return Base::getNeighborFrame().convertToGlobalBasis(lq - m_ul * (lq.dot(m_ul)) / sqnorm);
24 Scalar potential = potentialLocal(lq);
25 VectorType grad = primitiveGradientLocal(lq);
26 Scalar norm = grad.norm();
27 Scalar t = -(norm - sqrt(norm * norm - Scalar(4) * m_uq * potential)) / (Scalar(2) * m_uq * norm);
28 return Base::getNeighborFrame().convertToGlobalBasis(lq + t * grad);
32template <
class DataPo
int,
class _NFilter,
typename T>
33 requires ALGEBRAIC_SPHERE_REQUIREMENTS
34typename AlgebraicSphere<DataPoint, _NFilter, T>::Scalar AlgebraicSphere<DataPoint, _NFilter, T>::potentialLocal(
35 const VectorType& _lq)
const
37 return m_uc + _lq.dot(m_ul) + m_uq * _lq.squaredNorm();
40template <
class DataPo
int,
class _NFilter,
typename T>
41 requires ALGEBRAIC_SPHERE_REQUIREMENTS
42typename AlgebraicSphere<DataPoint, _NFilter, T>::VectorType AlgebraicSphere<
43 DataPoint, _NFilter, T>::primitiveGradientLocal(
const VectorType& _lq)
const
45 return (m_ul + Scalar(2.) * m_uq * _lq);