Ponca  bab7704293a2c36e5bed9dea40def7ba839bfe08
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
12#include "./defines.h"
13#include "./plane.h"
14#include "./primitive.h"
15#include "./mean.h" // used to define CovarianceLineFit
16#include "./covarianceFit.h" // use to define CovariancePlaneFit
17
18#include <Eigen/Eigenvalues>
19
20namespace Ponca
21{
22
33 template <class DataPoint, class _NFilter, typename T>
34 class CovariancePlaneFitImpl : public T
35 {
36 PONCA_FITTING_DECLARE_DEFAULT_TYPES
37 PONCA_FITTING_DECLARE_MATRIX_TYPE
38
39 protected:
40 enum
41 {
42 Check = Base::PROVIDES_PLANE && Base::PROVIDES_POSITION_COVARIANCE,
50 };
51
52 public:
53 PONCA_EXPLICIT_CAST_OPERATORS(CovariancePlaneFitImpl, covariancePlaneFit)
54 PONCA_FITTING_DECLARE_FINALIZE
55 PONCA_FITTING_IS_SIGNED(false)
56
57 /**************************************************************************/
58 /* Results */
59 /**************************************************************************/
60
61
71 PONCA_MULTIARCH inline VectorType worldToTangentPlane(const VectorType& _q,
72 bool _isPositionVector = true) const;
73
82 PONCA_MULTIARCH inline VectorType tangentPlaneToWorld(const VectorType& _q,
83 bool _isPositionVector = true) const;
84 }; // class CovariancePlaneFitImpl
85
88 template <class DataPoint, class _NFilter, typename T>
90 DataPoint, _NFilter,
91 CovarianceFitBase<DataPoint, _NFilter, MeanPosition<DataPoint, _NFilter, Plane<DataPoint, _NFilter, T>>>>;
93
100 template <class DataPoint, class _NFilter, int DiffType, typename T>
101 class CovariancePlaneDerImpl : public T
102 {
103 PONCA_FITTING_DECLARE_DEFAULT_TYPES
104 PONCA_FITTING_DECLARE_MATRIX_TYPE
105 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
106 static_assert(DataPoint::Dim == 3, "CovariancePlaneDer is only valid in 3D");
107
108 protected:
109 enum
110 {
111 Check = Base::PROVIDES_PLANE & Base::PROVIDES_POSITION_COVARIANCE_DERIVATIVE,
113 PROVIDES_NORMAL_DERIVATIVE
114 };
115
116 private:
117 VectorArray m_dNormal{VectorArray::Zero()};
118 ScalarArray m_dDist{ScalarArray::Zero()};
120 public:
121 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovariancePlaneDerImpl, covariancePlaneDer)
122
123
124 PONCA_MULTIARCH FIT_RESULT finalize();
125
126 /**************************************************************************/
127 /* Use results */
128 /**************************************************************************/
129
130 // \brief Returns the derivatives of the scalar field at the evaluation point
132 PONCA_MULTIARCH [[nodiscard]] inline ScalarArray dPotential() const { return m_dDist; }
133
135 PONCA_MULTIARCH [[nodiscard]] inline VectorArray dNormal() const { return m_dNormal; }
136
137 }; // class CovariancePlaneDer
138
140 template <class DataPoint, class _NFilter, int DiffType, typename T>
142 DataPoint, _NFilter, DiffType,
144
145#include "covariancePlaneFit.hpp"
146
147} // namespace Ponca
Procedure that compute and decompose the covariance matrix of the neighbors positions in .
Internal generic class computing the derivatives of covariance matrix computed by CovarianceFitBase.
[CovariancePlaneFit Definition]
typename Base::ScalarArray ScalarArray
Alias to scalar derivatives array.
typename Base::VectorArray VectorArray
Alias to vector derivatives array.
@ PROVIDES_COVARIANCE_PLANE_DERIVATIVE
Provides derivatives for hyper-planes.
VectorArray dNormal() const
Returns the derivatives of the primitive normal.
Plane fitting procedure using only points position.
VectorType tangentPlaneToWorld(const VectorType &_q, bool _isPositionVector=true) const
Transform a point from the tangent plane [h, u, v]^T to ambient space.
FIT_RESULT finalize()
Finalize the procedure.
CovariancePlaneFitImpl< DataPoint, _NFilter, T > & covariancePlaneFit()
Explicit conversion to CovariancePlaneFitImpl , to access methods potentially hidden by heritage.
VectorType worldToTangentPlane(const VectorType &_q, bool _isPositionVector=true) const
Express a point in ambient space relatively to the tangent plane.
@ PROVIDES_TANGENT_PLANE_BASIS
Expose a method worldToTangentPlane(VectorType), which turns a point in ambient 3D space to the tange...
typename Base::VectorType VectorType
Alias to vector type.
Compute the barycenter of the input points.
Definition mean.h:26
Implicit hyperplane defined by an homogeneous vector .
Definition plane.h:36
This Source Code Form is subject to the terms of the Mozilla Public License, v.
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