Skip to content

Commit 310fc00

Browse files
committed
Merge remote-tracking branch 'origin/develop'
2 parents 681ed70 + 82ccb85 commit 310fc00

2 files changed

Lines changed: 43 additions & 1 deletion

File tree

include/boost/math/interpolators/detail/bezier_polynomial_detail.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class bezier_polynomial_imp
7373
}
7474
}
7575

76-
decasteljau_recursion(scratch_space, scratch_space.size(), t);
76+
decasteljau_recursion(scratch_space, control_points_.size() - 1, t);
7777
return scratch_space[0];
7878
}
7979

test/git_issue_959.cpp

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright Matt Borland, 2023
2+
// Use, modification and distribution are subject to the
3+
// Boost Software License, Version 1.0.
4+
// (See accompanying file LICENSE_1_0.txt
5+
// or copy at http://www.boost.org/LICENSE_1_0.txt)
6+
7+
#include <iostream>
8+
#include <array>
9+
#include <vector>
10+
#include <boost/math/interpolators/bezier_polynomial.hpp>
11+
12+
using tControlPoints = std::vector<std::array<double, 3>>;
13+
14+
void interpolateWithPoints(tControlPoints cp)
15+
{
16+
const auto cpSize = cp.size();
17+
auto bp = boost::math::interpolators::bezier_polynomial(std::move(cp));
18+
19+
// Interpolate at t = 0.5:
20+
std::array<double, 3> point = bp(0.5);
21+
std::cout << cpSize << " points, t = 0.5:\n";
22+
23+
for (const auto& c : point)
24+
{
25+
std::cout << " " << c << "\n";
26+
}
27+
}
28+
29+
30+
int main(void)
31+
{
32+
auto cp3 = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}};
33+
interpolateWithPoints(cp3);
34+
35+
auto cp4 = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}, {0,0,1}};
36+
interpolateWithPoints(cp4);
37+
38+
auto cp3b = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}};
39+
interpolateWithPoints(cp3b);
40+
41+
return 0;
42+
}

0 commit comments

Comments
 (0)