From c12a6407d98c995cee6f9dab7bac9719a51d7564 Mon Sep 17 00:00:00 2001 From: King_DuckZ Date: Fri, 1 Aug 2014 16:42:42 +0200 Subject: [PATCH] Bugfix in Line class. A constructor was wrong and the loop was wrong as well. --- src/line.hpp | 3 ++- src/line.inl | 19 +++++++++++++------ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/src/line.hpp b/src/line.hpp index d0b37fd..9b12d3a 100644 --- a/src/line.hpp +++ b/src/line.hpp @@ -31,9 +31,10 @@ namespace cloonel { typedef T Scalar; Line ( void ) {} + explicit Line ( Scalar parValue ); Line ( const Line& parOther ); Line ( const Point& parStart, const Point& parEnd ); - Line ( const Point& parStart, const Point& parDirection, Scalar parLength ) : Line(parStart, parDirection * parLength) { } + Line ( const Point& parStart, const Point& parDirection, Scalar parLength ) : Line(parStart, parStart + parDirection * parLength) { } ~Line ( void ) noexcept = default; Point& Start ( void ) { return m_points.x(); } diff --git a/src/line.inl b/src/line.inl index 91e6929..8487f5c 100644 --- a/src/line.inl +++ b/src/line.inl @@ -7,6 +7,14 @@ namespace cloonel { { } + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + template + Line::Line (Scalar parValue) : + m_points(Point(parValue)) + { + } + ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template @@ -14,13 +22,13 @@ namespace cloonel { m_points(parStart, parEnd) { } + ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template Line& Line::operator+= (const Point& parRhs) { - for (uint32_t z = 0; z < S; ++z) { - m_points[z] += parRhs; - } + m_points.x() += parRhs; + m_points.y() += parRhs; return *this; } @@ -28,9 +36,8 @@ namespace cloonel { ///-------------------------------------------------------------------------- template Line& Line::operator-= (const Point& parRhs) { - for (uint32_t z = 0; z < S; ++z) { - m_points[z] -= parRhs; - } + m_points.x() -= parRhs; + m_points.y() -= parRhs; return *this; }