00001 # ifndef Coord_h
00002 # define Coord_h Coord_h
00003
00004 # include "Root.h"
00005 # include <stdint.h>
00006
00007 namespace Conjecture {
00016 class Coord : public Root {
00017 public:
00018 u2 x;
00019 u2 y;
00020
00021
00022
00023
00024 Coord(u2 x,u2 y) { this->x = x; this->y = y; }
00025
00026 Coord(const Coord& coord) { this->x = coord.x; this->y = coord.y; }
00027 std::string str(int prec = 2) const;
00028
00029 Coord operator+(const Coord& c) const { return Coord(this->x+c.x,this->y+c.y); }
00030 Coord operator+(u2 val) const { return Coord(this->x+val,this->y+val); }
00031
00032 Coord& operator+=(const Coord& c) { this->x += c.x; this->y += c.y; return *this; }
00033 Coord& operator+=(u2 val) { this->x += val; this->y += val; return *this; }
00034
00035 Coord operator-(const Coord& c) const { return Coord(this->x-c.x,this->y-c.y); }
00036 Coord operator-(u2 val) const { return Coord(this->x-val,this->y-val); }
00037
00038 Coord& operator-=(const Coord& c) { this->x -= c.x; this->y -= c.y; return *this; }
00039 Coord& operator-=(u2 val) { this->x -= val; this->y -= val; return *this; }
00040
00046 bool operator<(const Coord& c) const { return ( (this->x*this->x+this->y*this->y) < (c.x*c.x + c.y*c.y)) ? true : false; }
00047
00053 bool withinBounds(const Coord& topleft, const Coord& bottomright) const;
00054 };
00055 };
00056
00057 # endif // Coord_h
00058