quintic_spline.h 1.64 KB
Newer Older
1
/**
Steve Tonneau's avatar
Steve Tonneau committed
2
* \file cubic_spline.h
3
4
5
6
7
* \brief Definition of a cubic spline.
* \author Steve T.
* \version 0.1
* \date 06/17/2013
*
8
9
10
* This file contains definitions for the CubicFunction struct.
* It allows the creation and evaluation of natural
* smooth cubic splines of arbitrary dimension
11
12
13
*/


Steve Tonneau's avatar
Steve Tonneau committed
14
15
#ifndef _STRUCT_QUINTIC_SPLINE
#define _STRUCT_QUINTIC_SPLINE
16
17

#include "MathDefs.h"
18

19
#include "polynomial.h"
20

21
22
#include <stdexcept>

23
namespace curves
24
{
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
  /// \brief Creates coefficient vector of a quintic spline defined on the interval
  /// \f$[t_{min}, t_{max}]\f$. It follows the equation :<br>
  /// \f$ x(t) = a + b(t - t_{min}) + c(t - t_{min})^2 + d(t - t_{min})^3 + e(t - t_{min})^4  + f(t - t_{min})^5 \f$ <br>
  /// where \f$ t \in [t_{min}, t_{max}] \f$.
  ///
  template<typename Point, typename T_Point>
  T_Point make_quintic_vector(Point const& a, Point const& b, Point const& c,
  Point const &d, Point const& e, Point const& f)
  {
    T_Point res;
    res.push_back(a);res.push_back(b);res.push_back(c);
    res.push_back(d);res.push_back(e);res.push_back(f);
    return res;
  }

  template<typename Time, typename Numeric, std::size_t Dim, bool Safe, typename Point, typename T_Point>
  polynomial<Time,Numeric,Dim,Safe,Point,T_Point> create_quintic(Point const& a, Point const& b, Point const& c, Point const &d, Point const &e, Point const &f,
  const Time t_min, const Time t_max)
  {
    T_Point coeffs = make_quintic_vector<Point, T_Point>(a,b,c,d,e,f);
    return polynomial<Time,Numeric,Dim,Safe,Point,T_Point>(coeffs.begin(),coeffs.end(), t_min, t_max);
  }
47
} // namespace curves
Steve Tonneau's avatar
Steve Tonneau committed
48
#endif //_STRUCT_QUINTIC_SPLINE
49