Main MRPT website > C++ reference for MRPT 1.9.9
interp_fit.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2018, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
12 #include <mrpt/math/wrap2pi.h>
13 
14 namespace mrpt
15 {
16 namespace math
17 {
18 /** @addtogroup interpolation_grp Interpolation, least-squares fit, splines
19  * \ingroup mrpt_math_grp
20  * @{ */
21 
22 /** Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced),
23  * to obtain the approximation of the sequence at the point "x".
24  * If the point "x" is out of the range [x0,x1], the closest extreme "ys"
25  * value is returned.
26  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
27  * \sa spline, interpolate2points
28  */
29 template <class T, class VECTOR>
30 T interpolate(const T& x, const VECTOR& ys, const T& x0, const T& x1);
31 
32 /** Linear interpolation/extrapolation: evaluates at "x" the line
33  * (x0,y0)-(x1,y1).
34  * If wrap2pi is true, output is wrapped to ]-pi,pi] (It is assumed that input
35  * "y" values already are in the correct range).
36  * \sa spline, interpolate, leastSquareLinearFit
37  */
38 double interpolate2points(
39  const double x, const double x0, const double y0, const double x1,
40  const double y1, bool wrap2pi = false);
41 
42 /** Interpolates the value of a function in a point "t" given 4 SORTED points
43  * where "t" is between the two middle points
44  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
45  * assumed that input "y" values already are in the correct range).
46  * \sa leastSquareLinearFit
47  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
48  */
49 template <typename NUMTYPE, class VECTORLIKE>
50 NUMTYPE spline(
51  const NUMTYPE t, const VECTORLIKE& x, const VECTORLIKE& y,
52  bool wrap2pi = false);
53 
54 /** Interpolates or extrapolates using a least-square linear fit of the set of
55  * values "x" and "y", evaluated at a single point "t".
56  * The vectors x and y must have size >=2, and all values of "x" must be
57  * different.
58  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
59  * assumed that input "y" values already are in the correct range).
60  * \sa spline
61  * \sa getRegressionLine, getRegressionPlane
62  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
63  */
64 template <typename NUMTYPE, class VECTORLIKE, int NUM_POINTS = Eigen::Dynamic>
65 NUMTYPE leastSquareLinearFit(
66  const NUMTYPE t, const VECTORLIKE& x, const VECTORLIKE& y,
67  bool wrap2pi = false);
68 
69 /** Interpolates or extrapolates using a least-square linear fit of the set of
70  * values "x" and "y", evaluated at a sequence of points "ts" and returned at
71  * "outs".
72  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
73  * assumed that input "y" values already are in the correct range).
74  * \sa spline, getRegressionLine, getRegressionPlane
75  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
76  */
77 template <class VECTORLIKE1, class VECTORLIKE2, class VECTORLIKE3,
78  int NUM_POINTS = Eigen::Dynamic>
80  const VECTORLIKE1& ts, VECTORLIKE2& outs, const VECTORLIKE3& x,
81  const VECTORLIKE3& y, bool wrap2pi = false);
82 
83 /** @} */ // end grouping interpolation_grp
84 
85 } // End of MATH namespace
86 } // End of namespace
t
GLdouble GLdouble t
Definition: glext.h:3689
mrpt::math::interpolate
T interpolate(const T &x, const VECTOR &ys, const T &x0, const T &x1)
Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced), to obtain the approximat...
Definition: interp_fit.hpp:19
mrpt::math::spline
NUMTYPE spline(const NUMTYPE t, const VECTORLIKE &x, const VECTORLIKE &y, bool wrap2pi=false)
Interpolates the value of a function in a point "t" given 4 SORTED points where "t" is between the tw...
Definition: interp_fit.hpp:36
wrap2pi.h
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
CMatrixTemplateNumeric.h
mrpt::math::leastSquareLinearFit
NUMTYPE leastSquareLinearFit(const NUMTYPE t, const VECTORLIKE &x, const VECTORLIKE &y, bool wrap2pi=false)
Interpolates or extrapolates using a least-square linear fit of the set of values "x" and "y",...
Definition: interp_fit.hpp:121
mrpt::math::interpolate2points
double interpolate2points(const double x, const double x0, const double y0, const double x1, const double y1, bool wrap2pi=false)
Linear interpolation/extrapolation: evaluates at "x" the line (x0,y0)-(x1,y1).
Definition: math.cpp:436
y
GLenum GLint GLint y
Definition: glext.h:3538
x
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST