Ponca  aa50bfdf187919869239c5b44b748842569114c1
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 return Base::m_w.convertToGlobalBasis( lq + t * grad );
30}
31
32template < class DataPoint, class _WFunctor, typename T>
35{
36 PONCA_MULTIARCH_STD_MATH(min)
37
38 // turn to centered basis
39 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
40
41 VectorType grad;
42 VectorType dir = m_ul+Scalar(2.)*m_uq*lq;
43 Scalar ilg = Scalar(1.)/dir.norm();
44 dir = dir*ilg;
45 Scalar ad = m_uc + m_ul.dot(lq) + m_uq * lq.squaredNorm();
46 Scalar delta = -ad*min(ilg,Scalar(1.));
47 VectorType proj = lq + dir*delta;
48
49 for (int i=0; i<nbIter; ++i)
50 {
51 grad = m_ul+Scalar(2.)*m_uq*proj;
52 ilg = Scalar(1.)/grad.norm();
53 delta = -(m_uc + proj.dot(m_ul) + m_uq * proj.squaredNorm())*min(ilg,Scalar(1.));
54 proj += dir*delta;
55 }
56 return Base::m_w.convertToGlobalBasis( proj );
57}
58
59template < class DataPoint, class _WFunctor, typename T>
62{
63 // turn to centered basis
64 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
65
66 return m_uc + lq.dot(m_ul) + m_uq * lq.squaredNorm();
67}
68
69
70template < class DataPoint, class _WFunctor, typename T>
73{
74 // turn to centered basis
75 const VectorType lq = Base::m_w.convertToLocalBasis(_q);
76 return (m_ul + Scalar(2.f) * m_uq * lq);
77}
78
Algebraic Sphere primitive.
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename Base::VectorType VectorType
Alias to vector type.