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



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020