18 std::array<double, 3> qBsplines{ 0.0, 0.0, 0.0 };
19 std::array<double, 4> knots{};
21 for (
size_t splineIterator = 0; splineIterator < 3; splineIterator++)
23 if (ti >= 2.0 * splineSpacing)
25 knots.at(3) = ti - std::fmod(ti, splineSpacing) + splineSpacing *
static_cast<double>(splineIterator + 1);
26 knots.at(2) = knots.at(3) - splineSpacing;
27 knots.at(1) = knots.at(3) - 2.0 * splineSpacing;
28 knots.at(0) = knots.at(3) - 3.0 * splineSpacing;
30 else if ((ti >= splineSpacing) && (ti < 2.0 * splineSpacing))
32 switch (splineIterator)
35 knots = { 0.0, 0.0, 1.0 * splineSpacing, 2.0 * splineSpacing };
38 knots = { 0.0, 1.0 * splineSpacing, 2.0 * splineSpacing, 3.0 * splineSpacing };
41 knots = { 1.0 * splineSpacing, 2.0 * splineSpacing, 3.0 * splineSpacing, 4.0 * splineSpacing };
48 else if (ti < 1.0 * splineSpacing)
50 switch (splineIterator)
53 knots = { 0.0, 0.0, 0.0, 1.0 * splineSpacing };
56 knots = { 0.0, 0.0, 1.0 * splineSpacing, 2.0 * splineSpacing };
59 knots = { 0.0, 1.0 * splineSpacing, 2.0 * splineSpacing, 3.0 * splineSpacing };
67 LOG_DATA(
"ti = {}, B-spline '{}', knots = {}, {}, {}, {}", ti, splineIterator, knots.at(0), knots.at(1), knots.at(2), knots.at(3));
70 std::array<double, 3> N0{};
71 if ((knots.at(0) <= ti) && (ti < knots.at(1)))
75 else if ((knots.at(1) <= ti) && (ti < knots.at(2)))
79 else if ((knots.at(2) <= ti) && (ti < knots.at(3)))
85 std::array<double, 2> N1{};
91 if ((knots.at(0) <= ti) && (ti < knots.at(2)))
93 if (knots.at(1) - knots.at(0) != 0.0)
95 N11_factor1 = (ti - knots.at(0)) / (knots.at(1) - knots.at(0));
97 if (knots.at(2) - knots.at(1) != 0.0)
99 N11_factor2 = (knots.at(2) - ti) / (knots.at(2) - knots.at(1));
101 N1.at(0) = N11_factor1 * N0.at(0) + N11_factor2 * N0.at(1);
103 if ((knots.at(1) <= ti) && (ti < knots.at(3)))
105 if (knots.at(2) - knots.at(1) != 0.0)
107 N12_factor1 = (ti - knots.at(1)) / (knots.at(2) - knots.at(1));
109 if (knots.at(3) - knots.at(2) != 0.0)
111 N12_factor2 = (knots.at(3) - ti) / (knots.at(3) - knots.at(2));
113 N1.at(1) = N12_factor1 * N0.at(1) + N12_factor2 * N0.at(2);
120 if (knots.at(2) - knots.at(0) != 0.0)
122 N2_factor1 = (ti - knots.at(0)) / (knots.at(2) - knots.at(0));
124 if (knots.at(3) - knots.at(1) != 0.0)
126 N2_factor2 = (knots.at(3) - ti) / (knots.at(3) - knots.at(1));
128 qBsplines.at(splineIterator) = N2_factor1 * N1.at(0) + N2_factor2 * N1.at(1);