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-2017, 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 
11 #include <mrpt/utils/utils_defs.h>
13 #include <mrpt/math/wrap2pi.h>
14 
15 namespace mrpt
16 {
17 namespace math
18 {
19 /** @addtogroup interpolation_grp Interpolation, least-squares fit, splines
20  * \ingroup mrpt_base_grp
21  * @{ */
22 
23 /** Interpolate a data sequence "ys" ranging from "x0" to "x1" (equally spaced),
24  * to obtain the approximation of the sequence at the point "x".
25  * If the point "x" is out of the range [x0,x1], the closest extreme "ys"
26  * value is returned.
27  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
28  * \sa spline, interpolate2points
29  */
30 template <class T, class VECTOR>
31 T interpolate(const T& x, const VECTOR& ys, const T& x0, const T& x1);
32 
33 /** Linear interpolation/extrapolation: evaluates at "x" the line
34  * (x0,y0)-(x1,y1).
35  * If wrap2pi is true, output is wrapped to ]-pi,pi] (It is assumed that input
36  * "y" values already are in the correct range).
37  * \sa spline, interpolate, leastSquareLinearFit
38  */
39 double interpolate2points(
40  const double x, const double x0, const double y0, const double x1,
41  const double y1, bool wrap2pi = false);
42 
43 /** Interpolates the value of a function in a point "t" given 4 SORTED points
44  * where "t" is between the two middle points
45  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
46  * assumed that input "y" values already are in the correct range).
47  * \sa leastSquareLinearFit
48  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
49  */
50 template <typename NUMTYPE, class VECTORLIKE>
51 NUMTYPE spline(
52  const NUMTYPE t, const VECTORLIKE& x, const VECTORLIKE& y,
53  bool wrap2pi = false);
54 
55 /** Interpolates or extrapolates using a least-square linear fit of the set of
56  * values "x" and "y", evaluated at a single point "t".
57  * The vectors x and y must have size >=2, and all values of "x" must be
58  * different.
59  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
60  * assumed that input "y" values already are in the correct range).
61  * \sa spline
62  * \sa getRegressionLine, getRegressionPlane
63  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
64  */
65 template <typename NUMTYPE, class VECTORLIKE, int NUM_POINTS = Eigen::Dynamic>
66 NUMTYPE leastSquareLinearFit(
67  const NUMTYPE t, const VECTORLIKE& x, const VECTORLIKE& y,
68  bool wrap2pi = false);
69 
70 /** Interpolates or extrapolates using a least-square linear fit of the set of
71  * values "x" and "y", evaluated at a sequence of points "ts" and returned at
72  * "outs".
73  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
74  * assumed that input "y" values already are in the correct range).
75  * \sa spline, getRegressionLine, getRegressionPlane
76  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
77  */
78 template <class VECTORLIKE1, class VECTORLIKE2, class VECTORLIKE3,
79  int NUM_POINTS = Eigen::Dynamic>
81  const VECTORLIKE1& ts, VECTORLIKE2& outs, const VECTORLIKE3& x,
82  const VECTORLIKE3& y, bool wrap2pi = false);
83 
84 /** @} */ // end grouping interpolation_grp
85 
86 } // End of MATH namespace
87 } // End of namespace
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:114
GLdouble GLdouble t
Definition: glext.h:3689
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:17
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
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:37
GLenum GLint GLint y
Definition: glext.h:3538
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:1975
GLenum GLint x
Definition: glext.h:3538



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: ae4571287 Thu Nov 23 00:06:53 2017 +0100 at dom oct 27 23:51:55 CET 2019