Wiselib
|
00001 // vim: set noexpandtab ts=3 sw=3: 00002 00003 #ifndef POSITION_H 00004 #define POSITION_H 00005 00006 namespace wiselib { 00007 template< 00008 typename OsModel_P, 00009 typename Real_P 00010 > 00011 class Position2D { 00012 public: 00013 typedef OsModel_P OsModel; 00014 typedef Real_P Real; 00015 00016 Position2D() { 00017 x_ = 0; 00018 y_ = 0; 00019 } 00020 00021 Position2D(Real x, Real y) { 00022 x_ = x; 00023 y_ = y; 00024 } 00025 00026 Position2D(const Position2D& other) { 00027 x_ = other.x_; 00028 y_ = other.y_; 00029 } 00030 00031 Position2D& operator=(const Position2D& other) { 00032 x_ = other.x_; 00033 y_ = other.y_; 00034 return *this; 00035 } 00036 00037 Position2D operator+(const Position2D& other) const { 00038 return Position2D(x + other.x, y + other.y); 00039 } 00040 00041 Position2D& operator+=(const Position2D& other) { 00042 x_ += other.x_; 00043 y_ += other.y_; 00044 return *this; 00045 } 00046 00047 Position2D operator-(const Position2D& other) const { 00048 return Position2D(x_ - other.x_, y_ - other.y_); 00049 } 00050 00051 Position2D& operator-=(const Position2D& other) { 00052 x_ -= other.x_; 00053 y_ -= other.y_; 00054 return *this; 00055 } 00056 00057 Real x() const { return x_; } 00058 Real y() const { return y_; } 00059 00060 private: 00061 Real x_, y_; 00062 }; 00063 00064 } // namespace wiselib 00065 00066 #endif // POSITION_H 00067