Ponca  73247abfe24d29406a95aee1d4dfa2d34da85d4c
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 PONCA_MULTIARCH_INCLUDE_STD(cmath)
14#include PONCA_MULTIARCH_INCLUDE_CU_STD(limits)
15
16#include <Eigen/Dense>
17
18namespace Ponca
19{
20
58 template <class DataPoint, class _NFilter, typename T>
59 class CovarianceFitBase : public T
60 {
61 PONCA_FITTING_DECLARE_DEFAULT_TYPES
62
63 protected:
64 enum
65 {
66 Check = Base::PROVIDES_MEAN_POSITION,
67 PROVIDES_POSITION_COVARIANCE
68 };
69
70 public:
71 using MatrixType = typename DataPoint::MatrixType;
73 using Solver = Eigen::SelfAdjointEigenSolver<MatrixType>;
74
75 protected:
76 // computation data
77 MatrixType m_cov{MatrixType::Zero()};
80 public:
81 PONCA_EXPLICIT_CAST_OPERATORS(CovarianceFitBase, covarianceFit)
82 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
83
89 PONCA_MULTIARCH [[nodiscard]] inline Scalar surfaceVariation() const;
90
95 PONCA_MULTIARCH [[nodiscard]] inline Scalar planarity() const;
96
101 PONCA_MULTIARCH [[nodiscard]] inline Scalar linearity() const;
102
107 PONCA_MULTIARCH [[nodiscard]] inline Scalar sphericity() const;
108
113 PONCA_MULTIARCH [[nodiscard]] inline Scalar anisotropy() const;
114
119 PONCA_MULTIARCH [[nodiscard]] inline Scalar eigenentropy() const;
120
123 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_0() const;
124
127 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_1() const;
128
131 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_2() const;
132
134 PONCA_MULTIARCH [[nodiscard]] inline const Solver& solver() const { return m_solver; }
135 };
136
142 template <class DataPoint, class _NFilter, int DiffType, typename T>
143 class CovarianceFitDer : public T
144 {
145 PONCA_FITTING_DECLARE_DEFAULT_TYPES
146 PONCA_FITTING_DECLARE_MATRIX_TYPE
147 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
148
149 protected:
150 enum
151 {
152 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE && Base::PROVIDES_MEAN_POSITION_DERIVATIVE &&
153 Base::PROVIDES_POSITION_COVARIANCE,
154 PROVIDES_POSITION_COVARIANCE_DERIVATIVE
155 };
156
157 protected:
159 MatrixType m_dCov[Base::NbDerivatives];
160
161 public:
162 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovarianceFitDer, covarianceFitDer)
163 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
164 }; // class CovarianceFitDer
165
166#include "covarianceFit.hpp"
167
168} // namespace Ponca
Aggregator class used to declare specialized structures using CRTP.
Definition basket.h:318
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.