Ponca  4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
Point Cloud Analysis library
Loading...
Searching...
No Matches
covariancePlaneFit.h
1/*
2 Copyright (C) 2014 Nicolas Mellado <nmellado0@gmail.com>
3 Copyright (C) 2015 Gael Guennebaud <gael.guennebaud@inria.fr>
4
5 This Source Code Form is subject to the terms of the Mozilla Public
6 License, v. 2.0. If a copy of the MPL was not distributed with this
7 file, You can obtain one at http://mozilla.org/MPL/2.0/.
8*/
9
10#pragma once
11#include "../../defines.h"
12#include "../concepts.h"
13
14#include "../primitive/plane.h" // used to define CovariancePlaneFit
15#include "../tools/mean.h" // used to define CovariancePlaneFit
16#include "../tools/covariance.h" // used to define CovariancePlaneFit
17
18#include <Eigen/Eigenvalues>
19
20#define COVARIANCE_PLANE_FIT_REQUIREMENTS ProvidesPlane<T>
21#define COVARIANCE_PLANE_DER_REQUIREMENTS ProvidesPlane<T>&& Is3D<DataPoint>
22
23namespace Ponca
24{
25
36 template <class DataPoint, class _NFilter, typename T>
37 requires COVARIANCE_PLANE_FIT_REQUIREMENTS
38 class CovariancePlaneFitImpl : public T
39 {
40 PONCA_FITTING_DECLARE_DEFAULT_TYPES
41 PONCA_FITTING_DECLARE_MATRIX_TYPE
42 public:
43 PONCA_EXPLICIT_CAST_OPERATORS(CovariancePlaneFitImpl, covariancePlaneFit)
44 PONCA_EXPLICIT_CAST_OPERATORS(CovariancePlaneFitImpl, tangentPlaneBasis)
45 PONCA_FITTING_DECLARE_FINALIZE
46 PONCA_FITTING_IS_SIGNED(false)
47
48 /**************************************************************************/
49 /* Results */
50 /**************************************************************************/
51
64
75 }; // class CovariancePlaneFitImpl
76
79 template <class DataPoint, class _NFilter, typename T>
81 DataPoint, _NFilter,
82 CovarianceBase<DataPoint, _NFilter, MeanPosition<DataPoint, _NFilter, Plane<DataPoint, _NFilter, T>>>>;
84
91 template <class DataPoint, class _NFilter, int DiffType, typename T>
92 requires COVARIANCE_PLANE_DER_REQUIREMENTS
94 {
95 PONCA_FITTING_DECLARE_DEFAULT_TYPES
96 PONCA_FITTING_DECLARE_MATRIX_TYPE
97 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
98 private:
99 VectorArray m_dNormal{VectorArray::Zero()};
100 ScalarArray m_dDist{ScalarArray::Zero()};
102 public:
103 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovariancePlaneDerImpl, covariancePlaneDer)
104 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovariancePlaneDerImpl, implicitPrimitiveDer)
105
107 PONCA_MULTIARCH FIT_RESULT finalize();
108
109 /**************************************************************************/
110 /* Use results */
111 /**************************************************************************/
112
113 // \brief Returns the derivatives of the scalar field at the evaluation point
115 PONCA_MULTIARCH [[nodiscard]] inline ScalarArray dPotential() const { return m_dDist; }
116
118 PONCA_MULTIARCH [[nodiscard]] inline VectorArray dNormal() const { return m_dNormal; }
119
120 }; // class CovariancePlaneDer
121
123 template <class DataPoint, class _NFilter, int DiffType, typename T>
125 DataPoint, _NFilter, DiffType,
127
128#include "covariancePlaneFit.hpp"
129
130} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:260
Procedure that compute and decompose the covariance matrix of the neighbors positions.
Definition covariance.h:66
[CovariancePlaneFit Definition]
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
VectorArray dNormal() const
Returns the derivatives of the primitive normal.
Plane fitting procedure using only points position.
CovariancePlaneFitImpl< DataPoint, _NFilter, T > & covariancePlaneFit()
Explicit conversion to CovariancePlaneFitImpl , to access methods potentially hidden by heritage.
CovariancePlaneFitImpl< DataPoint, _NFilter, T > & tangentPlaneBasis()
Explicit conversion to CovariancePlaneFitImpl , to access methods potentially hidden by heritage.
FIT_RESULT finalize()
Finalize the procedure.
VectorType tangentPlaneToWorld(const VectorType &_q, bool _isPositionVector=true) const
Transform a point from the tangent plane [h, u, v]^T to ambient space.
VectorType worldToTangentPlane(const VectorType &_q, bool _isPositionVector=true) const
Express a point in ambient space relatively to the tangent plane.
typename Base::VectorType VectorType
Alias to vector type.
Compute the barycenter of the input points.
Definition mean.h:28
Implicit hyperplane defined by an homogeneous vector .
Definition plane.h:39
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
DiffType
Flags defining which derivatives need to be computed.
Definition enums.h:34
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns)
Definition enums.h:15