diff --git a/src/line.hpp b/src/line.hpp index 9b12d3a..edbd38e 100644 --- a/src/line.hpp +++ b/src/line.hpp @@ -44,6 +44,8 @@ namespace cloonel { Line& operator+= ( const Point& parRhs ) __attribute__((flatten)); Line& operator-= ( const Point& parRhs ) __attribute__((flatten)); + template + Line& operator*= ( const Vector& parRhs ) __attribute__((flatten)); private: Vector m_points; @@ -57,6 +59,10 @@ namespace cloonel { Line operator+ ( const Vector& parLhs, Line parRhs ) __attribute__((pure)) __attribute__((flatten)); template Line operator- ( const Vector& parLhs, Line parRhs ) __attribute__((pure)) __attribute__((flatten)); + template + Line operator* ( const Vector& parLhs, Line parRhs ) __attribute__((pure)) __attribute__((flatten)); + template + Line operator* ( Line parLhs, const Vector& parRhs ) __attribute__((pure)) __attribute__((flatten)); template bool operator> ( const Vector& parLhs, const Line& parRhs ) __attribute__((pure)); diff --git a/src/line.inl b/src/line.inl index 6aae70b..354fb23 100644 --- a/src/line.inl +++ b/src/line.inl @@ -44,7 +44,17 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template - Line operator+ ( const Vector& parLhs, Line parRhs ) { + template + Line& Line::operator*= (const Vector& parRhs) { + m_points.x() = static_cast(m_points.x() * parRhs); + m_points.y() = static_cast(m_points.y() * parRhs); + return *this; + } + + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + template + Line operator+ (const Vector& parLhs, Line parRhs) { parRhs += parLhs; return parRhs; } @@ -52,7 +62,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template - Line operator- ( const Vector& parLhs, Line parRhs ) { + Line operator- (const Vector& parLhs, Line parRhs) { parRhs -= parLhs; return parRhs; } @@ -60,7 +70,7 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template - Line operator+ ( Line parLhs, const Vector& parRhs ) { + Line operator+ (Line parLhs, const Vector& parRhs) { parLhs += parRhs; return parLhs; } @@ -68,11 +78,27 @@ namespace cloonel { ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template - Line operator- ( Line parLhs, const Vector& parRhs ) { + Line operator- (Line parLhs, const Vector& parRhs) { parLhs -= parRhs; return parLhs; } + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + template + Line operator* (const Vector& parLhs, Line parRhs) { + parRhs *= parLhs; + return parRhs; + } + + ///-------------------------------------------------------------------------- + ///-------------------------------------------------------------------------- + template + Line operator* (Line parLhs, const Vector& parRhs) { + parLhs *= parRhs; + return parLhs; + } + ///-------------------------------------------------------------------------- ///-------------------------------------------------------------------------- template