Bugfix in Line class.

A constructor was wrong and the loop was wrong as well.
This commit is contained in:
King_DuckZ 2014-08-01 16:42:42 +02:00
parent 3522ce37a3
commit c12a6407d9
2 changed files with 15 additions and 7 deletions

View file

@ -31,9 +31,10 @@ namespace cloonel {
typedef T Scalar; typedef T Scalar;
Line ( void ) {} Line ( void ) {}
explicit Line ( Scalar parValue );
Line ( const Line& parOther ); Line ( const Line& parOther );
Line ( const Point& parStart, const Point& parEnd ); 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; ~Line ( void ) noexcept = default;
Point& Start ( void ) { return m_points.x(); } Point& Start ( void ) { return m_points.x(); }

View file

@ -7,6 +7,14 @@ namespace cloonel {
{ {
} }
///--------------------------------------------------------------------------
///--------------------------------------------------------------------------
template <typename T, uint32_t S>
Line<T, S>::Line (Scalar parValue) :
m_points(Point(parValue))
{
}
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, uint32_t S> template <typename T, uint32_t S>
@ -14,13 +22,13 @@ namespace cloonel {
m_points(parStart, parEnd) m_points(parStart, parEnd)
{ {
} }
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, uint32_t S> template <typename T, uint32_t S>
Line<T, S>& Line<T, S>::operator+= (const Point& parRhs) { Line<T, S>& Line<T, S>::operator+= (const Point& parRhs) {
for (uint32_t z = 0; z < S; ++z) { m_points.x() += parRhs;
m_points[z] += parRhs; m_points.y() += parRhs;
}
return *this; return *this;
} }
@ -28,9 +36,8 @@ namespace cloonel {
///-------------------------------------------------------------------------- ///--------------------------------------------------------------------------
template <typename T, uint32_t S> template <typename T, uint32_t S>
Line<T, S>& Line<T, S>::operator-= (const Point& parRhs) { Line<T, S>& Line<T, S>::operator-= (const Point& parRhs) {
for (uint32_t z = 0; z < S; ++z) { m_points.x() -= parRhs;
m_points[z] -= parRhs; m_points.y() -= parRhs;
}
return *this; return *this;
} }