1 /* "THE BEER-WARE LICENSE" (Revision 42): Devin Lane wrote this file. As long as you retain
2 * this notice you can do whatever you want with this stuff. If we meet some day, and you
3 * think this stuff is worth it, you can buy me a beer in return. */
4
5 #include "SplineCoeff.h"
6
SplineCoeff(double t,const SplinePair & a,const SplinePair & b,const SplinePair & c,const SplinePair & d)7 SplineCoeff::SplineCoeff(double t,
8 const SplinePair &a,
9 const SplinePair &b,
10 const SplinePair &c,
11 const SplinePair &d) :
12 m_t(t),
13 m_a(a),
14 m_b(b),
15 m_c(c),
16 m_d(d)
17 {
18 }
19
operator <(const SplineCoeff & c) const20 bool SplineCoeff::operator<(const SplineCoeff &c) const
21 {
22 return m_t < c.t();
23 }
24
operator <(double t) const25 bool SplineCoeff::operator<(double t) const
26 {
27 return m_t < t;
28 }
29
a() const30 SplinePair SplineCoeff::a () const
31 {
32 return m_a;
33 }
34
b() const35 SplinePair SplineCoeff::b () const
36 {
37 return m_b;
38 }
39
c() const40 SplinePair SplineCoeff::c () const
41 {
42 return m_c;
43 }
44
d() const45 SplinePair SplineCoeff::d () const
46 {
47 return m_d;
48 }
49
eval(double t) const50 SplinePair SplineCoeff::eval(double t) const
51 {
52 double deltat = t - m_t;
53 return m_a + m_b * deltat + m_c * (deltat * deltat) + m_d * (deltat * deltat * deltat);
54 }
55
t() const56 double SplineCoeff::t () const
57 {
58 return m_t;
59 }
60