Ponca  40f245e28b920cbb763a1c6282156c87c626f24c
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
52 template < class DataPoint, class _WFunctor, typename T>
53 class CovarianceFitBase : public T
54 {
55 PONCA_FITTING_DECLARE_DEFAULT_TYPES
56
57 protected:
58 enum
59 {
60 Check = Base::PROVIDES_MEAN_POSITION,
61 PROVIDES_POSITION_COVARIANCE
62 };
63
64 public:
65 using MatrixType = typename DataPoint::MatrixType;
67 using Solver = Eigen::SelfAdjointEigenSolver<MatrixType>;
68
69 protected:
70 // computation data
71 MatrixType m_cov {MatrixType::Zero()};
74 public:
75 PONCA_EXPLICIT_CAST_OPERATORS(CovarianceFitBase,covarianceFit)
76 PONCA_FITTING_DECLARE_INIT_ADD_FINALIZE
77
82 PONCA_MULTIARCH inline Scalar surfaceVariation() const;
83
88 PONCA_MULTIARCH inline Scalar planarity() const;
89
94 PONCA_MULTIARCH inline Scalar linearity() const;
95
100 PONCA_MULTIARCH inline Scalar sphericity() const;
101
106 PONCA_MULTIARCH inline Scalar anisotropy() const;
107
112 PONCA_MULTIARCH inline Scalar eigenentropy() const;
113
116 PONCA_MULTIARCH inline Scalar lambda_0() const;
117
120 PONCA_MULTIARCH inline Scalar lambda_1() const;
121
124 PONCA_MULTIARCH inline Scalar lambda_2() const;
125
127 PONCA_MULTIARCH inline const Solver& solver() const { return m_solver; }
128 };
129
130
136 template < class DataPoint, class _WFunctor, int DiffType, typename T>
137 class CovarianceFitDer : public T
138 {
139 PONCA_FITTING_DECLARE_DEFAULT_TYPES
140 PONCA_FITTING_DECLARE_MATRIX_TYPE
141 PONCA_FITTING_DECLARE_DEFAULT_DER_TYPES
142
143 protected:
144 enum
145 {
146 Check = Base::PROVIDES_PRIMITIVE_DERIVATIVE &&
147 Base::PROVIDES_MEAN_POSITION_DERIVATIVE &&
148 Base::PROVIDES_POSITION_COVARIANCE,
149 PROVIDES_POSITION_COVARIANCE_DERIVATIVE
150 };
151
152 protected:
154 MatrixType m_dCov[Base::NbDerivatives];
155
156 public:
157 PONCA_EXPLICIT_CAST_OPERATORS_DER(CovarianceFitDer,covarianceFitDer)
158 PONCA_FITTING_DECLARE_INIT_ADDDER_FINALIZE
159 }; //class CovarianceFitDer
160
161#include "covarianceFit.hpp"
162
163} //namespace Ponca
Procedure that compute and decompose the covariance matrix of the neighbors positions in .
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
Scalar sphericity() const
Implements the sphericity .
Eigen::SelfAdjointEigenSolver< MatrixType > Solver
Solver used to analyse the covariance matrix.
Scalar lambda_2() const
The maximun eigenvalue .
MatrixType m_cov
Covariance matrix.
Scalar lambda_1() const
The second eigenvalue .
typename DataPoint::Scalar Scalar
Alias to scalar type.
Solver m_solver
Solver used to analyse the covariance matrix.
const Solver & solver() const
Reading access to the Solver used to analyse the covariance matrix.
Scalar eigenentropy() const
Implements the eigenentropy .
CovarianceFitBase< DataPoint, _WFunctor, T > & covarianceFit()
Explicit conversion to CovarianceFitBase , to access methods potentially hidden by heritage.
Scalar linearity() const
Implements the linearity .
Scalar lambda_0() const
The minimun eigenvalue .
Scalar planarity() const
Implements the planarity .
Scalar surfaceVariation() const
Implements surface variation.
Scalar anisotropy() const
Implements the anisotropy .
Internal generic class computing the derivatives of covariance matrix computed by CovarianceFitBase.
typename DataPoint::MatrixType MatrixType
Alias to matrix type.
MatrixType m_dCov[Base::NbDerivatives]
Computation data: derivatives of the covariance matrix.
CovarianceFitDer< DataPoint, _WFunctor, DiffType, T > & covarianceFitDer()
Explicit conversion to CovarianceFitDer , to access methods potentially hidden by heritage.
This Source Code Form is subject to the terms of the Mozilla Public License, v.