MRPT  1.9.9
interp_fit.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://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 <
63  typename NUMTYPE, class VECTORLIKE, int NUM_POINTS = -1 /*Eigen::Dynamic*/>
64 NUMTYPE leastSquareLinearFit(
65  const NUMTYPE t, const VECTORLIKE& x, const VECTORLIKE& y,
66  bool wrap2pi = false);
67 
68 /** Interpolates or extrapolates using a least-square linear fit of the set of
69  * values "x" and "y", evaluated at a sequence of points "ts" and returned at
70  * "outs".
71  * If wrap2pi is true, output "y" values are wrapped to ]-pi,pi] (It is
72  * assumed that input "y" values already are in the correct range).
73  * \sa spline, getRegressionLine, getRegressionPlane
74  * \note Implementation in `#include <mrpt/math/interp_fit.hpp>`
75  * \note Requires `#include <Eigen/Dense>`
76  */
77 template <
78  class VECTORLIKE1, class VECTORLIKE2, class VECTORLIKE3,
79  int NUM_POINTS = -1 /*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 } // namespace mrpt::math
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
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
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:438



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: c7a3bec24 Sun Mar 29 18:33:13 2020 +0200 at dom mar 29 18:50:38 CEST 2020