Ponca  bab7704293a2c36e5bed9dea40def7ba839bfe08
Point Cloud Analysis library
Loading...
Searching...
No Matches
covarianceFit.h
1/*
2 Copyright (C) 2021 aniket agarwalla <aniketagarwalla37@gmail.com>
3 Copyright (C) 2022 nicolas mellado <nmellado0@gmail.com>
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
13#include <Eigen/Dense>
14
15namespace Ponca
16{
17
55 template <class DataPoint, class _NFilter, typename T>
56 class CovarianceFitBase : public T
57 {
58 PONCA_FITTING_DECLARE_DEFAULT_TYPES
59
60 protected:
61 enum
62 {
63 Check = Base::PROVIDES_MEAN_POSITION,
64 PROVIDES_POSITION_COVARIANCE
65 };
66
67 public:
68 using MatrixType = typename DataPoint::MatrixType;
70 using Solver = Eigen::SelfAdjointEigenSolver<MatrixType>;
71
72 protected:
73 // computation data
74 MatrixType m_cov{MatrixType::Zero()};
77 public:
78 PONCA_EXPLICIT_CAST_OPERATORS(CovarianceFitBase, covarianceFit)
79 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
80
86 PONCA_MULTIARCH [[nodiscard]] inline Scalar surfaceVariation() const;
87
92 PONCA_MULTIARCH [[nodiscard]] inline Scalar planarity() const;
93
98 PONCA_MULTIARCH [[nodiscard]] inline Scalar linearity() const;
99
104 PONCA_MULTIARCH [[nodiscard]] inline Scalar sphericity() const;
105
110 PONCA_MULTIARCH [[nodiscard]] inline Scalar anisotropy() const;
111
116 PONCA_MULTIARCH [[nodiscard]] inline Scalar eigenentropy() const;
117
120 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_0() const;
121
124 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_1() const;
125
128 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_2() const;
129
131 PONCA_MULTIARCH [[nodiscard]] inline const Solver& solver() const { return m_solver; }
132 };
133
139 template <class DataPoint, class _NFilter, int DiffType, typename T>
140 class CovarianceFitDer : public T
141 {
142 PONCA_FITTING_DECLARE_DEFAULT_TYPES
143 PONCA_FITTING_DECLARE_MATRIX_TYPE
144 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
145
146 protected:
147 enum
148 {
149 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE && Base::PROVIDES_MEAN_POSITION_DERIVATIVE &&
150 Base::PROVIDES_POSITION_COVARIANCE,
151 PROVIDES_POSITION_COVARIANCE_DERIVATIVE
152 };
153
154 protected:
156 MatrixType m_dCov[Base::NbDerivatives];
157
158 public:
159 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovarianceFitDer, covarianceFitDer)
160 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
161 }; // class CovarianceFitDer
162
163#include "covarianceFit.hpp"
164
165} // namespace Ponca
Procedure that compute and decompose the covariance matrix of the neighbors positions in .
Eigen::SelfAdjointEigenSolver< MatrixType > Solver
Solver used to analyse the covariance matrix.
const Solver & solver() const
Reading access to the Solver used to analyse the covariance matrix.
Solver m_solver
Solver used to analyse the covariance matrix.
Scalar sphericity() const
Implements the sphericity .
Scalar surfaceVariation() const
Implements surface variation.
Scalar lambda_2() const
The maximum eigenvalue .
Scalar lambda_1() const
The second eigenvalue .
typename DataPoint::Scalar Scalar
Alias to scalar type.
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Scalar eigenentropy() const
Implements the eigenentropy .
Scalar linearity() const
Implements the linearity .
CovarianceFitBase< DataPoint, _NFilter, T > & covarianceFit()
Explicit conversion to CovarianceFitBase , to access methods potentially hidden by heritage.
Scalar lambda_0() const
The minimum eigenvalue .
Scalar planarity() const
Implements the planarity .
MatrixType m_cov
Covariance matrix.
Scalar anisotropy() const
Implements the anisotropy .
Internal generic class computing the derivatives of covariance matrix computed by CovarianceFitBase.
CovarianceFitDer< DataPoint, _NFilter, DiffType, T > & covarianceFitDer()
Explicit conversion to CovarianceFitDer , to access methods potentially hidden by heritage.
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
MatrixType m_dCov[Base::NbDerivatives]
Computation data: derivatives of the covariance matrix.
This Source Code Form is subject to the terms of the Mozilla Public License, v.