Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for issue #959 #960

Merged
merged 2 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}