bezier: use correct degree parameter
This commit is contained in:
parent
bd12519d94
commit
8a43c0f416
14
bezier.cpp
14
bezier.cpp
@ -27,9 +27,9 @@
|
|||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
template <size_t S>
|
template <size_t S>
|
||||||
util::bezier<S>::bezier (const util::point2f _points[S])
|
util::bezier<S>::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<S>::bezier (const util::point2f _points[S])
|
|||||||
namespace util {
|
namespace util {
|
||||||
template <>
|
template <>
|
||||||
point2f
|
point2f
|
||||||
bezier<2>::eval (float t)
|
bezier<1>::eval (float t) const
|
||||||
{
|
{
|
||||||
CHECK_GE (t, 0);
|
CHECK_GE (t, 0);
|
||||||
CHECK_LE (t, 1);
|
CHECK_LE (t, 1);
|
||||||
@ -57,7 +57,7 @@ namespace util {
|
|||||||
namespace util {
|
namespace util {
|
||||||
template <>
|
template <>
|
||||||
point2f
|
point2f
|
||||||
bezier<3>::eval (float t)
|
bezier<2>::eval (float t) const
|
||||||
{
|
{
|
||||||
CHECK_GE (t, 0);
|
CHECK_GE (t, 0);
|
||||||
CHECK_LE (t, 1);
|
CHECK_LE (t, 1);
|
||||||
@ -78,7 +78,7 @@ namespace util {
|
|||||||
namespace util {
|
namespace util {
|
||||||
template <>
|
template <>
|
||||||
point2f
|
point2f
|
||||||
bezier<4>::eval (float t)
|
bezier<3>::eval (float t) const
|
||||||
{
|
{
|
||||||
CHECK_GE (t, 0);
|
CHECK_GE (t, 0);
|
||||||
CHECK_LE (t, 1);
|
CHECK_LE (t, 1);
|
||||||
@ -101,7 +101,7 @@ template <size_t S>
|
|||||||
util::point2f&
|
util::point2f&
|
||||||
util::bezier<S>::operator[] (size_t idx)
|
util::bezier<S>::operator[] (size_t idx)
|
||||||
{
|
{
|
||||||
CHECK_LT (idx, S);
|
CHECK_LE (idx, S);
|
||||||
|
|
||||||
return m_points[idx];
|
return m_points[idx];
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ template <size_t S>
|
|||||||
const util::point2f&
|
const util::point2f&
|
||||||
util::bezier<S>::operator[] (size_t idx) const
|
util::bezier<S>::operator[] (size_t idx) const
|
||||||
{
|
{
|
||||||
CHECK_LT (idx, S);
|
CHECK_LE (idx, S);
|
||||||
|
|
||||||
return m_points[idx];
|
return m_points[idx];
|
||||||
}
|
}
|
||||||
|
@ -25,16 +25,17 @@
|
|||||||
namespace util {
|
namespace util {
|
||||||
template <size_t S>
|
template <size_t S>
|
||||||
class bezier {
|
class bezier {
|
||||||
bezier (const util::point2f[S]);
|
public:
|
||||||
|
bezier (const util::point2f (&)[S+1]);
|
||||||
|
|
||||||
point2f eval (float t);
|
point2f eval (float t) const;
|
||||||
float distance (point2f);
|
float distance (point2f) const;
|
||||||
|
|
||||||
point2f& operator[] (size_t idx);
|
point2f& operator[] (size_t idx);
|
||||||
const point2f& operator[] (size_t idx) const;
|
const point2f& operator[] (size_t idx) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
point2f m_points[S];
|
point2f m_points[S+1];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user