-
Notifications
You must be signed in to change notification settings - Fork 0
/
spline.h
33 lines (26 loc) · 1023 Bytes
/
spline.h
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
#ifndef _BPJ_BYTEIMAGE_SPLINE_H
#define _BPJ_BYTEIMAGE_SPLINE_H
#include "matrix.h"
#include <vector>
namespace byteimage {
class Spline {
protected:
std::vector<Matrix> d;//De Boor points
std::vector<double> U;//Knot vector
public:
inline void addPoint(Matrix pt) {d.push_back(pt);}
inline void addKnot(double u) {U.push_back(u);}
inline Matrix& operator[](int i) {return d[i];}
inline const Matrix& operator[](int i) const {return d[i];}
inline int countPoints() const {return d.size();}
inline double& getKnot(int i) {return U[i];}
inline double getKnot(int i) const {return U[i];}
inline int countKnots() const {return U.size();}
inline int degree() const {return countKnots() - countPoints() + 1;}
inline double domainStart() const {return U.at(degree() - 1);}
inline double domainEnd() const {return U.at(U.size() - degree());}
Matrix at(double u) const;
static Spline makeSpline(int degree, std::initializer_list<Matrix> pts);
};
}
#endif