00001 # ifndef Conjecture_Coord_h
00002 # define Conjecture_Coord_h Conjecture_Coord_h
00003
00004
00005
00006
00007 # include "Root.h"
00008 # include <stdint.h>
00009
00010 namespace Conjecture {
00019 class Coord : public Root {
00020 public:
00021 u2 x;
00022 u2 y;
00023
00024
00025
00026
00027 Coord(u2 x,u2 y) { this->x = x; this->y = y; }
00028
00029 Coord(const Coord& coord) { this->x = coord.x; this->y = coord.y; }
00030 std::string str(int prec = 2) const;
00031
00032 Coord operator+(const Coord& c) const { return Coord(this->x+c.x,this->y+c.y); }
00033 Coord operator+(u2 val) const { return Coord(this->x+val,this->y+val); }
00034
00035 Coord& operator+=(const Coord& c) { this->x += c.x; this->y += c.y; return *this; }
00036 Coord& operator+=(u2 val) { this->x += val; this->y += val; return *this; }
00037
00038 Coord operator-(const Coord& c) const { return Coord(this->x-c.x,this->y-c.y); }
00039 Coord operator-(u2 val) const { return Coord(this->x-val,this->y-val); }
00040
00041 Coord& operator-=(const Coord& c) { this->x -= c.x; this->y -= c.y; return *this; }
00042 Coord& operator-=(u2 val) { this->x -= val; this->y -= val; return *this; }
00043
00049 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; }
00050
00056 bool withinBounds(const Coord& topleft, const Coord& bottomright) const;
00057 };
00058 };
00059
00060 # endif // Conjecture_Coord_h
00061