/* Copyright 2014 Michele "King_DuckZ" Santullo This file is part of CloonelJump. CloonelJump is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. CloonelJump is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with CloonelJump. If not, see . */ #ifndef id56F112C6551D44039D0C0270F573B35B #define id56F112C6551D44039D0C0270F573B35B #include "compatibility.h" #include "vectypes.hpp" #include "vectorwrapper/vectorops.hpp" #include #include namespace cloonel { template class Line { public: typedef Vector Point; 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, parStart + parDirection * parLength) { } Line ( Scalar parX1, Scalar parY1, Scalar parX2, Scalar parY2 ); ~Line ( void ) noexcept = default; Point& Start ( void ) { return m_points.x(); } Point& End ( void ) { return m_points.y(); } const Point& Start ( void ) const { return m_points.x(); } const Point& End ( void ) const { return m_points.y(); } Point& operator[] ( int parIndex ) { assert(parIndex >= 0); return m_points[static_cast(parIndex)]; } const Point& operator[] ( int parIndex ) const { assert(parIndex >= 0); return m_points[static_cast(parIndex)]; } Point& operator[] ( uint32_t parIndex ) { return m_points[parIndex]; } const Point& operator[] ( uint32_t parIndex ) const { return m_points[parIndex]; } Line& operator+= ( const Point& parRhs ) a_flatten; Line& operator-= ( const Point& parRhs ) a_flatten; template Line& operator*= ( const Vector& parRhs ) a_flatten; private: Vector m_points; }; template Line operator+ ( Line parLhs, const Vector& parRhs ) a_pure a_flatten; template Line operator- ( Line parLhs, const Vector& parRhs ) a_pure a_flatten; template Line operator+ ( const Vector& parLhs, Line parRhs ) a_pure a_flatten; template Line operator- ( const Vector& parLhs, Line parRhs ) a_pure a_flatten; template Line operator* ( const Vector& parLhs, Line parRhs ) a_pure a_flatten; template Line operator* ( Line parLhs, const Vector& parRhs ) a_pure a_flatten; template bool operator> ( const Vector& parLhs, const Line& parRhs ) a_pure; template bool operator< ( const Vector& parLhs, const Line& parRhs ) a_pure; template bool operator>= ( const Vector& parLhs, const Line& parRhs ) a_pure; template bool operator<= ( const Vector& parLhs, const Line& parRhs ) a_pure; } //namespace cloonel #include "line.inl" #endif