Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-21 09:41:22

0001 // Copyright Nick Thompson, 2021
0002 // Use, modification and distribution are subject to the
0003 // Boost Software License, Version 1.0.
0004 // (See accompanying file LICENSE_1_0.txt
0005 // or copy at http://www.boost.org/LICENSE_1_0.txt)
0006 #ifndef BOOST_MATH_INTERPOLATORS_BEZIER_POLYNOMIAL_HPP
0007 #define BOOST_MATH_INTERPOLATORS_BEZIER_POLYNOMIAL_HPP
0008 #include <memory>
0009 #include <boost/math/interpolators/detail/bezier_polynomial_detail.hpp>
0010 
0011 #ifdef BOOST_MATH_NO_THREAD_LOCAL_WITH_NON_TRIVIAL_TYPES
0012 #warning "Thread local storage support is necessary for the Bezier polynomial class to work."
0013 #endif
0014 
0015 namespace boost::math::interpolators {
0016 
0017 template <class RandomAccessContainer>
0018 class bezier_polynomial
0019 {
0020 public:
0021     using Point = typename RandomAccessContainer::value_type;
0022     using Real = typename Point::value_type;
0023     using Z = typename RandomAccessContainer::size_type;
0024 
0025     bezier_polynomial(RandomAccessContainer && control_points)
0026     : m_imp(std::make_shared<detail::bezier_polynomial_imp<RandomAccessContainer>>(std::move(control_points)))
0027     {
0028     }
0029 
0030     inline Point operator()(Real t) const
0031     {
0032         return (*m_imp)(t);
0033     }
0034 
0035     inline Point prime(Real t) const
0036     {
0037         return m_imp->prime(t);
0038     }
0039 
0040     void edit_control_point(Point const & p, Z index)
0041     {
0042         m_imp->edit_control_point(p, index);
0043     }
0044 
0045     RandomAccessContainer const & control_points() const
0046     {
0047         return m_imp->control_points();
0048     }
0049 
0050     friend std::ostream& operator<<(std::ostream& out, bezier_polynomial<RandomAccessContainer> const & bp) {
0051         out << *bp.m_imp;
0052         return out;
0053     }
0054 
0055 private:
0056     std::shared_ptr<detail::bezier_polynomial_imp<RandomAccessContainer>> m_imp;
0057 };
0058 
0059 }
0060 #endif