Ponca  cfb0fcc680f97b3ab7288990161ce80053655869
Point Cloud Analysis library
Loading...
Searching...
No Matches
project.h
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#pragma once
7
8namespace Ponca
9{
14 {
15 public:
24 template <typename Fit>
25 PONCA_MULTIARCH typename Fit::VectorType project(const Fit& _f, const typename Fit::VectorType& _pos) const
26 {
27 return _f.project(_pos);
28 }
29
33 template <typename Fit>
34 PONCA_MULTIARCH typename Fit::VectorType operator()(const Fit& _f, const typename Fit::VectorType& _pos) const
35 {
36 return project(_f, _pos);
37 }
38 };
39
49 {
50 public:
51 GradientDescentProjectionOperator(unsigned int _nbIter = 16) : nbIter(_nbIter) {}
52
61 template <typename Fit>
62 PONCA_MULTIARCH typename Fit::VectorType project(const Fit& _f, const typename Fit::VectorType& _pos) const
63 {
64 PONCA_MULTIARCH_STD_MATH(min)
65 using VectorType = typename Fit::VectorType;
66 using Scalar = typename Fit::Scalar;
67
68 VectorType grad;
69 VectorType dir = _f.primitiveGradient(_pos);
70 Scalar ilg = Scalar(1.) / dir.norm();
71 dir = dir * ilg;
72 Scalar ad = _f.potential(_pos);
73 Scalar delta = -ad * min(ilg, Scalar(1.));
74 VectorType proj = _pos + dir * delta;
75
76 for (unsigned int i = 0; i < nbIter; ++i)
77 {
78 grad = _f.primitiveGradient(proj);
79 ilg = Scalar(1.) / grad.norm();
80 delta = -_f.potential(proj) * min(ilg, Scalar(1.));
81 proj += dir * delta;
82 }
83 return proj;
84 }
85
89 template <typename Fit>
90 PONCA_MULTIARCH typename Fit::VectorType operator()(const Fit& f, const typename Fit::VectorType& pos) const
91 {
92 return project(f, pos);
93 }
94
95 public:
96 unsigned int nbIter;
97 };
98}; // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:257
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Project a point using the primitive projection operator.
Definition project.h:14
Fit::VectorType project(const Fit &_f, const typename Fit::VectorType &_pos) const
Project a point using the primitive projection operator.
Definition project.h:25
Fit::VectorType operator()(const Fit &_f, const typename Fit::VectorType &_pos) const
Project a point using the primitive projection operator.
Definition project.h:34
Project a point using the gradinet of the sdf.
Definition project.h:49
Fit::VectorType operator()(const Fit &f, const typename Fit::VectorType &pos) const
Project a point using the gradinet of the sdf.
Definition project.h:90
Fit::VectorType project(const Fit &_f, const typename Fit::VectorType &_pos) const
Project a point using the gradinet of the sdf.
Definition project.h:62