Ponca  6f9f1b59d7c8c4654a710cfcef7342f4f5c79ba1
Point Cloud Analysis library
Loading...
Searching...
No Matches
algebraicSphere.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> // Outer template for the class
8 requires ALGEBRAIC_SPHERE_REQUIREMENTS
9typename AlgebraicSphere<DataPoint, _NFilter, T>::VectorType // Return type
11{
12 PONCA_MULTIARCH_STD_MATH(sqrt);
13
14 // turn to centered basis
15 const VectorType lq = Base::getNeighborFrame().convertToLocalBasis(_q);
16
17 if (isPlane())
18 {
19 Scalar sqnorm = m_ul.squaredNorm();
20 return Base::getNeighborFrame().convertToGlobalBasis(lq - m_ul * (lq.dot(m_ul)) / sqnorm);
21 }
22 else
23 {
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);
29 }
30}
31
32template <class DataPoint, class _NFilter, typename T>
33 requires ALGEBRAIC_SPHERE_REQUIREMENTS
35 const VectorType& _lq) const
36{
37 return m_uc + _lq.dot(m_ul) + m_uq * _lq.squaredNorm();
38}
39
40template <class DataPoint, class _NFilter, typename T>
41 requires ALGEBRAIC_SPHERE_REQUIREMENTS
43 DataPoint, _NFilter, T>::primitiveGradientLocal(const VectorType& _lq) const
44{
45 return (m_ul + Scalar(2.) * m_uq * _lq);
46}
47
Algebraic Sphere primitive.
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename Base::VectorType VectorType
Alias to vector type.
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260