Ponca  4d2a58fa5c6375adef5c4b208f4d47e016cecd6d
Point Cloud Analysis library
Loading...
Searching...
No Matches
covariance.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#include "../concepts.h"
13
14#include PONCA_MULTIARCH_INCLUDE_STD(cmath)
15#include PONCA_MULTIARCH_INCLUDE_CU_STD(limits)
16
17#include <Eigen/Dense>
18
19#define COVARIANCE_FIT_BASE_REQUIREMENTS ProvidesMeanPosition<T>
20#define COVARIANCE_FIT_DER_REQUIREMENTS \
21 ProvidesBasketDiffUnitBase<T>&& ProvidesMeanPositionDerivative<T>&& ProvidesPositionCovariance<T>
22
23namespace Ponca
24{
25
63 template <class DataPoint, class _NFilter, typename T>
64 requires COVARIANCE_FIT_BASE_REQUIREMENTS
65 class CovarianceBase : public T
66 {
67 PONCA_FITTING_DECLARE_DEFAULT_TYPES
68 public:
69 using MatrixType = typename DataPoint::MatrixType;
71 using Solver = Eigen::SelfAdjointEigenSolver<MatrixType>;
72
73 protected:
74 // computation data
75 MatrixType m_cov{MatrixType::Zero()};
78 public:
79 PONCA_EXPLICIT_CAST_OPERATORS(CovarianceBase, covarianceBase)
80 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
81
87 PONCA_MULTIARCH [[nodiscard]] inline Scalar surfaceVariation() const;
88
94 PONCA_MULTIARCH [[nodiscard]] inline Scalar planarity() const;
95
101 PONCA_MULTIARCH [[nodiscard]] inline Scalar linearity() const;
102
108 PONCA_MULTIARCH [[nodiscard]] inline Scalar sphericity() const;
109
115 PONCA_MULTIARCH [[nodiscard]] inline Scalar anisotropy() const;
116
121 PONCA_MULTIARCH [[nodiscard]] inline Scalar eigenentropy() const;
122
125 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_0() const;
126
129 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_1() const;
130
133 PONCA_MULTIARCH [[nodiscard]] inline Scalar lambda_2() const;
134
136 PONCA_MULTIARCH [[nodiscard]] inline const Solver& solver() const { return m_solver; }
137 };
138
144 template <class DataPoint, class _NFilter, int DiffType, typename T>
145 requires COVARIANCE_FIT_DER_REQUIREMENTS
146 class CovarianceDer : public T
147 {
148 PONCA_FITTING_DECLARE_DEFAULT_TYPES
149 PONCA_FITTING_DECLARE_MATRIX_TYPE
150 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
151 protected:
153 MatrixType m_dCov[Base::NbDerivatives];
154
155 public:
156 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovarianceDer, covarianceDer)
157 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
158 }; // class CovarianceDer
159
160#include "covariance.hpp"
161
162} // 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
Scalar lambda_0() const
The minimum eigenvalue .
CovarianceBase< DataPoint, _NFilter, T > & covarianceBase()
Explicit conversion to CovarianceBase , to access methods potentially hidden by heritage.
Definition covariance.h:79
Scalar sphericity() const
Implements the sphericity .
Scalar lambda_2() const
The maximum eigenvalue .
Eigen::SelfAdjointEigenSolver< MatrixType > Solver
Solver used to analyse the covariance matrix.
Definition covariance.h:71
MatrixType m_cov
Covariance matrix.
Definition covariance.h:75
Scalar surfaceVariation() const
Implements surface variation.
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition covariance.h:69
typename DataPoint::Scalar Scalar
Alias to scalar type.
Definition covariance.h:67
Scalar lambda_1() const
The second eigenvalue .
Scalar planarity() const
Implements the planarity .
Solver m_solver
Solver used to analyse the covariance matrix.
Definition covariance.h:76
Scalar anisotropy() const
Implements the anisotropy .
Scalar linearity() const
Implements the linearity .
const Solver & solver() const
Reading access to the Solver used to analyze the covariance matrix.
Definition covariance.h:136
Scalar eigenentropy() const
Implements the eigenentropy .
Internal generic class computing the derivatives of covariance matrix computed by covarianceBase.
Definition covariance.h:147
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Definition covariance.h:149
CovarianceDer< DataPoint, _NFilter, DiffType, T > & covarianceDer()
Explicit conversion to CovarianceDer , to access methods potentially hidden by heritage.
Definition covariance.h:156
MatrixType m_dCov[Base::NbDerivatives]
Computation data: derivatives of the covariance matrix.
Definition covariance.h:153
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11