Ponca  e26a0e88a45818354616c1a7180bcd203aecad3c
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 "./linePrimitive.h" // used to define CovarianceLineFit
12#include "./mean.h" // used to define CovarianceLineFit
13#include "./covarianceFit.h" // used to define CovarianceLineFit
14
15#include <Eigen/Dense>
16
17namespace Ponca
18{
19
33template < class DataPoint, class _WFunctor, typename T>
34class CovarianceLineFitImpl : public T
35{
36 PONCA_FITTING_DECLARE_DEFAULT_TYPES
37 PONCA_FITTING_DECLARE_MATRIX_TYPE
38
39protected:
40 enum
41 {
42 check = Base::PROVIDES_LINE &&
43 Base::PROVIDES_POSITION_COVARIANCE,
44 };
45
46public:
47 PONCA_EXPLICIT_CAST_OPERATORS(CovarianceLineFitImpl,covarianceLineFit)
48
49 PONCA_FITTING_APIDOC_FINALIZE
50 PONCA_MULTIARCH inline FIT_RESULT finalize()
51 {
52 static const int smallestEigenValue = DataPoint::Dim - 1;
53 if (Base::finalize() == STABLE) {
54 if (Base::line().isValid()) Base::m_eCurrentState = CONFLICT_ERROR_FOUND;
55 Base::setLine(Base::barycenter(), Base::m_solver.eigenvectors().col(smallestEigenValue).normalized());
56 }
57 return Base::m_eCurrentState;
58 }
59 PONCA_FITTING_IS_SIGNED(false)
60};
61
63template < class DataPoint, class _WFunctor, typename T>
65 CovarianceLineFitImpl<DataPoint, _WFunctor,
66 CovarianceFitBase<DataPoint, _WFunctor,
67 MeanPosition<DataPoint, _WFunctor,
69
70} //namespace Ponca
Line fitting procedure that minimize the orthogonal distance between the samples and the fitted primi...
Definition: covarianceFit.h:33
Line fitting procedure that minimize the orthogonal distance between the samples and the fitted primi...
CovarianceLineFitImpl< DataPoint, _WFunctor, T > & covarianceLineFit()
Explicit conversion to CovarianceLineFitImpl , to access methods potentially hidden by heritage.
FIT_RESULT finalize()
Finalize the procedure.
A parametrized line is defined by an origin point and a unit direction vector such that the line co...
Definition: linePrimitive.h:36
Compute the barycenter of the input points.
Definition: mean.h:24
This Source Code Form is subject to the terms of the Mozilla Public License, v.
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