Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
mborland committed Mar 3, 2023
2 parents 681ed70 + 82ccb85 commit 310fc00
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class bezier_polynomial_imp
}
}

decasteljau_recursion(scratch_space, scratch_space.size(), t);
decasteljau_recursion(scratch_space, control_points_.size() - 1, t);
return scratch_space[0];
}

Expand Down
42 changes: 42 additions & 0 deletions test/git_issue_959.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright Matt Borland, 2023
// Use, modification and distribution are subject to the
// Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt
// or copy at http://www.boost.org/LICENSE_1_0.txt)

#include <iostream>
#include <array>
#include <vector>
#include <boost/math/interpolators/bezier_polynomial.hpp>

using tControlPoints = std::vector<std::array<double, 3>>;

void interpolateWithPoints(tControlPoints cp)
{
const auto cpSize = cp.size();
auto bp = boost::math::interpolators::bezier_polynomial(std::move(cp));

// Interpolate at t = 0.5:
std::array<double, 3> point = bp(0.5);
std::cout << cpSize << " points, t = 0.5:\n";

for (const auto& c : point)
{
std::cout << " " << c << "\n";
}
}


int main(void)
{
auto cp3 = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}};
interpolateWithPoints(cp3);

auto cp4 = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}, {0,0,1}};
interpolateWithPoints(cp4);

auto cp3b = tControlPoints{{0,0,0}, {1,0,0}, {0,1,0}};
interpolateWithPoints(cp3b);

return 0;
}

0 comments on commit 310fc00

Please sign in to comment.