61 lines · plain
1// Copyright Nick Thompson, 20212// Use, modification and distribution are subject to the3// Boost Software License, Version 1.0.4// (See accompanying file LICENSE_1_0.txt5// or copy at http://www.boost.org/LICENSE_1_0.txt)6#ifndef BOOST_MATH_INTERPOLATORS_BEZIER_POLYNOMIAL_HPP7#define BOOST_MATH_INTERPOLATORS_BEZIER_POLYNOMIAL_HPP8#include <memory>9#include <boost/math/interpolators/detail/bezier_polynomial_detail.hpp>10 11#ifdef BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES12#warning "Thread local storage support is necessary for the Bezier polynomial class to work."13#endif14 15namespace boost::math::interpolators {16 17template <class RandomAccessContainer>18class bezier_polynomial19{20public:21 using Point = typename RandomAccessContainer::value_type;22 using Real = typename Point::value_type;23 using Z = typename RandomAccessContainer::size_type;24 25 bezier_polynomial(RandomAccessContainer && control_points)26 : m_imp(std::make_shared<detail::bezier_polynomial_imp<RandomAccessContainer>>(std::move(control_points)))27 {28 }29 30 inline Point operator()(Real t) const31 {32 return (*m_imp)(t);33 }34 35 inline Point prime(Real t) const36 {37 return m_imp->prime(t);38 }39 40 void edit_control_point(Point const & p, Z index)41 {42 m_imp->edit_control_point(p, index);43 }44 45 RandomAccessContainer const & control_points() const46 {47 return m_imp->control_points();48 }49 50 friend std::ostream& operator<<(std::ostream& out, bezier_polynomial<RandomAccessContainer> const & bp) {51 out << *bp.m_imp;52 return out;53 }54 55private:56 std::shared_ptr<detail::bezier_polynomial_imp<RandomAccessContainer>> m_imp;57};58 59}60#endif61