19 namespace PhysicsTools {
39 d += coeffs[2] * tmp * 2.0;
41 d += coeffs[3] * tmp * 3.0;
48 area += coeffs[0] *
tmp;
50 area += coeffs[1] * tmp * (1.0 / 2.0);
52 area += coeffs[2] * tmp * (1.0 / 3.0);
54 area += coeffs[3] * tmp * (1.0 / 4.0);
65 Spline::Spline(
unsigned int n_,
const double *vals) :
n(0), segments(nullptr), area(0.0) {
set(n_, vals); }
77 seg->
coeffs[1] = vals[1] - vals[0];
87 m0 = 0.0, m1 = 0.5 * (vals[2] - vals[0]);
89 seg->
coeffs[1] = -2.0 * vals[0] + 2.0 * vals[1] - m1;
90 seg->
coeffs[2] = vals[0] - vals[1] + m1;
97 for (
unsigned int i = 1;
i <
n - 1;
i++, seg++, vals++) {
98 m1 = 0.5 * (vals[2] - vals[0]);
101 seg->coeffs[2] = -3.0 * vals[0] - 2.0 * m0 + 3.0 * vals[1] - m1;
102 seg->coeffs[3] = 2.0 * vals[0] + m0 - 2.0 * vals[1] + m1;
104 area = seg->integral(1.0);
108 seg->coeffs[0] = vals[0];
110 seg->coeffs[2] = -vals[0] - m0 + vals[1];
111 seg->coeffs[3] = 0.0;
113 area = seg->integral(1.0);
134 float rest = std::modf(x *
n, &total);
140 if (x < 0.0 || x > 1.0)
148 float rest = std::modf(x *
n, &total);
163 float rest = std::modf(x *
n, &total);