diff --git a/bezier.cpp b/bezier.cpp index 407dfc91..53dc04a7 100644 --- a/bezier.cpp +++ b/bezier.cpp @@ -27,9 +27,9 @@ //----------------------------------------------------------------------------- template -util::bezier::bezier (const util::point2f _points[S]) +util::bezier::bezier (const util::point2f (&_points)[S+1]) { - std::copy (_points, _points + S, m_points); + std::copy (_points, _points + S + 1, m_points); } @@ -37,7 +37,7 @@ util::bezier::bezier (const util::point2f _points[S]) namespace util { template <> point2f - bezier<2>::eval (float t) + bezier<1>::eval (float t) const { CHECK_GE (t, 0); CHECK_LE (t, 1); @@ -57,7 +57,7 @@ namespace util { namespace util { template <> point2f - bezier<3>::eval (float t) + bezier<2>::eval (float t) const { CHECK_GE (t, 0); CHECK_LE (t, 1); @@ -78,7 +78,7 @@ namespace util { namespace util { template <> point2f - bezier<4>::eval (float t) + bezier<3>::eval (float t) const { CHECK_GE (t, 0); CHECK_LE (t, 1); @@ -101,7 +101,7 @@ template util::point2f& util::bezier::operator[] (size_t idx) { - CHECK_LT (idx, S); + CHECK_LE (idx, S); return m_points[idx]; } @@ -112,7 +112,7 @@ template const util::point2f& util::bezier::operator[] (size_t idx) const { - CHECK_LT (idx, S); + CHECK_LE (idx, S); return m_points[idx]; } diff --git a/bezier.hpp b/bezier.hpp index 75bdef7d..a74baad3 100644 --- a/bezier.hpp +++ b/bezier.hpp @@ -25,16 +25,17 @@ namespace util { template class bezier { - bezier (const util::point2f[S]); + public: + bezier (const util::point2f (&)[S+1]); - point2f eval (float t); - float distance (point2f); + point2f eval (float t) const; + float distance (point2f) const; point2f& operator[] (size_t idx); const point2f& operator[] (size_t idx) const; private: - point2f m_points[S]; + point2f m_points[S+1]; }; }