-
Notifications
You must be signed in to change notification settings - Fork 17
/
Spline.hpp
88 lines (73 loc) · 1.93 KB
/
Spline.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#ifndef LEPH_SPLINE_HPP
#define LEPH_SPLINE_HPP
#include <vector>
#include <iostream>
#include "Polynom.hpp"
namespace Leph {
/**
* Spline
*
* Generic one dimentional
* polynomial spline generator
*/
class Spline
{
public:
/**
* Return spline interpolation
* at given t. Compute spline value,
* its first and second derivative
*/
double pos(double t) const;
double vel(double t) const;
double acc(double t) const;
/**
* Return spline interpolation
* value, first and second derivative
* with given t bound between 0 and 1
*/
double posMod(double t) const;
double velMod(double t) const;
double accMod(double t) const;
/**
* Return minimum and maximum abscisse
* value for which spline is defined
*/
double min() const;
double max() const;
/**
* Write and read splines data into given
* iostream in ascii format
*/
void exportData(std::ostream& os) const;
void importData(std::istream& is);
protected:
/**
* Internal spline part structure
* with a polynom valid on an interval
*/
struct Spline_t {
Polynom polynom;
double min;
double max;
};
/**
* Spline part container
*/
std::vector<Spline_t> _splines;
/**
* Return spline interpolation of given value and
* used given polynom evaluation function
* (member function pointer)
*/
double interpolation(double x,
double(Polynom::*func)(double) const) const;
/**
* Return interpolation with x
* bound between 0 and 1
*/
double interpolationMod(double x,
double(Polynom::*func)(double) const) const;
};
}
#endif