Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 244 | chris | 1 | #ifndef __POINT_H__ |
| 2 | #define __POINT_H__ |
||
| 3 | |||
| 4 | #include "Common.h" |
||
| 5 | |||
| 6 | namespace Sexy |
||
| 7 | { |
||
| 8 | |||
| 9 | template<class _T> class TPoint |
||
| 10 | { |
||
| 11 | public: |
||
| 12 | _T mX; |
||
| 13 | _T mY; |
||
| 14 | |||
| 15 | public: |
||
| 16 | TPoint(_T theX, _T theY) : |
||
| 17 | mX(theX), |
||
| 18 | mY(theY) |
||
| 19 | { |
||
| 20 | } |
||
| 21 | |||
| 22 | TPoint(const TPoint<_T>& theTPoint) : |
||
| 23 | mX(theTPoint.mX), |
||
| 24 | mY(theTPoint.mY) |
||
| 25 | { |
||
| 26 | } |
||
| 27 | |||
| 28 | TPoint() : |
||
| 29 | mX(0), |
||
| 30 | mY(0) |
||
| 31 | { |
||
| 32 | } |
||
| 33 | |||
| 34 | inline bool operator==(const TPoint& p) |
||
| 35 | { |
||
| 36 | return ((p.mX == mX) && (p.mY == mY)); |
||
| 37 | } |
||
| 38 | |||
| 39 | inline bool operator!=(const TPoint& p) |
||
| 40 | { |
||
| 41 | return ((p.mX != mX) || (p.mY != mY)); |
||
| 42 | } |
||
| 43 | |||
| 44 | TPoint operator+(const TPoint& p) const {return TPoint(mX+p.mX, mY+p.mY);} |
||
| 45 | TPoint operator-(const TPoint& p) const {return TPoint(mX-p.mX, mY-p.mY);} |
||
| 46 | TPoint operator*(const TPoint& p) const {return TPoint(mX*p.mX, mY*p.mY);} |
||
| 47 | TPoint operator/(const TPoint& p) const {return TPoint(mX/p.mX, mY/p.mY);} |
||
| 48 | TPoint& operator+=(const TPoint& p) {mX+=p.mX; mY+=p.mY; return *this;} |
||
| 49 | TPoint& operator-=(const TPoint& p) {mX-=p.mX; mY-=p.mY; return *this;} |
||
| 50 | TPoint& operator*=(const TPoint& p) {mX*=p.mX; mY*=p.mY; return *this;} |
||
| 51 | TPoint& operator/=(const TPoint& p) {mX/=p.mX; mY/=p.mY; return *this;} |
||
| 52 | TPoint operator*(_T s) const {return TPoint(mX*s, mY*s);} |
||
| 53 | TPoint operator/(_T s) const {return TPoint(mX/s, mY/s);} |
||
| 54 | }; |
||
| 55 | |||
| 56 | typedef TPoint<int> Point; |
||
| 57 | typedef TPoint<double> FPoint; |
||
| 58 | |||
| 59 | }; |
||
| 60 | |||
| 61 | #endif //__POINT_H__ |