Ponca  2cfe00173bb12dda99e12b2b48a0e1f683bc5cdd
Point Cloud Analysis library
Loading...
Searching...
No Matches
covarianceLineFit.h
1/*
2 Copyright (C) 2021 aniket agarwalla <aniketagarwalla37@gmail.com>
3
4 This Source Code Form is subject to the terms of the Mozilla Public
5 License, v. 2.0. If a copy of the MPL was not distributed with this
6 file, You can obtain one at http://mozilla.org/MPL/2.0/.
7*/
8
9#pragma once
10#include "../../defines.h"
11#include "../concepts.h"
12
13#include "../primitive/linePrimitive.h" // used to define CovarianceLineFit
14#include "../tools/mean.h" // used to define CovarianceLineFit
15#include "../tools/covariance.h" // used to define CovarianceLineFit
16
17#include <Eigen/Dense>
18
19#define COVARIANCE_LINE_FIT_REQUIREMENTS ProvidesPositionCovariance<T>&& ProvidesLine<T>
20
21namespace Ponca
22{
23
36
37 template <class DataPoint, class _NFilter, typename T>
38 requires COVARIANCE_LINE_FIT_REQUIREMENTS
39 class CovarianceLineFitImpl : public T
40 {
41 PONCA_FITTING_DECLARE_DEFAULT_TYPES
42 PONCA_FITTING_DECLARE_MATRIX_TYPE
43 public:
44 PONCA_EXPLICIT_BASKET_CAST_OPERATORS(CovarianceLineFitImpl, covarianceLineFit)
45
46 PONCA_FITTING_APIDOC_FINALIZE
47 PONCA_MULTIARCH inline FIT_RESULT finalize()
48 {
49 static const int smallestEigenValue = DataPoint::Dim - 1;
50 if (Base::finalize() == STABLE)
51 {
52 if (Base::line().isValid())
53 Base::m_eCurrentState = CONFLICT_ERROR_FOUND;
54 Base::setLine(Base::barycenterLocal(),
55 Base::m_solver.eigenvectors().col(smallestEigenValue).normalized());
56 }
57 return Base::m_eCurrentState;
58 }
59 PONCA_FITTING_IS_SIGNED(false)
60 };
61
63 template <class DataPoint, class _NFilter, typename T>
65 DataPoint, _NFilter,
67
68} // namespace Ponca
Procedure that compute and decompose the covariance matrix of the neighbors positions.
Definition covariance.h:66
Line fitting procedure that minimize the orthogonal distance between the samples and the fitted primi...
This Source Code Form is subject to the terms of the Mozilla Public License, v.
Definition concepts.h:11
CovarianceLineFitImpl< DataPoint, _NFilter, CovarianceBase< DataPoint, _NFilter, MeanPosition< DataPoint, _NFilter, Line< DataPoint, _NFilter, T > > > > CovarianceLineFit
Helper alias for Line fitting on 3D points using CovarianceLineFitImpl.
FIT_RESULT
Enum corresponding to the state of a fitting method (and what the finalize function returns).
Definition enums.h:15
@ CONFLICT_ERROR_FOUND
Multiple classes of the fitting procedure initialize the primitive.
Definition enums.h:27
@ STABLE
The fitting is stable and ready to use.
Definition enums.h:17