Ponca  f7f7d7cc113b4e53be6bee25005fbdbe7e016293
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 _WFunctor, typename T>
8typename AlgebraicSphere<DataPoint, _WFunctor, T>::VectorType
10{
11 PONCA_MULTIARCH_STD_MATH(sqrt);
12
13 // turn to centered basis
14 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
15
16 Scalar potential = m_uc + lq.dot(m_ul) + m_uq * lq.squaredNorm();
17 VectorType grad = m_ul + Scalar(2) * m_uq * lq;
18 Scalar norm = grad.norm();
19
20 Scalar t;
21 if(isPlane())
22 {
23 t = - potential / (norm*norm);
24 }
25 else
26 {
27 t = - (norm - sqrt(norm*norm - Scalar(4) * m_uq * potential)) / (Scalar(2) * m_uq * norm);
28 }
29
30 return Base::m_w.convertToGlobalBasis( lq + t * grad );
31}
32
33template < class DataPoint, class _WFunctor, typename T>
36{
37 PONCA_MULTIARCH_STD_MATH(min)
38
39 // turn to centered basis
40 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
41
42 VectorType grad;
43 VectorType dir = m_ul+Scalar(2.)*m_uq*lq;
44 Scalar ilg = Scalar(1.)/dir.norm();
45 dir = dir*ilg;
46 Scalar ad = m_uc + m_ul.dot(lq) + m_uq * lq.squaredNorm();
47 Scalar delta = -ad*min(ilg,Scalar(1.));
48 VectorType proj = lq + dir*delta;
49
50 for (int i=0; i<nbIter; ++i)
51 {
52 grad = m_ul+Scalar(2.)*m_uq*proj;
53 ilg = Scalar(1.)/grad.norm();
54 delta = -(m_uc + proj.dot(m_ul) + m_uq * proj.squaredNorm())*min(ilg,Scalar(1.));
55 proj += dir*delta;
56 }
57 return Base::m_w.convertToGlobalBasis( proj );
58}
59
60template < class DataPoint, class _WFunctor, typename T>
63{
64 // turn to centered basis
65 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
66
67 return m_uc + lq.dot(m_ul) + m_uq * lq.squaredNorm();
68}
69
70
71template < class DataPoint, class _WFunctor, typename T>
74{
75 // turn to centered basis
76 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
77 return (m_ul + Scalar(2.f) * m_uq * lq);
78}
79
Algebraic Sphere primitive.
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename Base::VectorType VectorType
Alias to vector type.