Coord.h

00001 # ifndef Conjecture_Coord_h
00002 # define Conjecture_Coord_h Conjecture_Coord_h
00003 
00004 // Insert SVN header substitution variable here
00005 // Class Champion: Unassigned
00006 
00007 # include "Root.h"
00008 # include <stdint.h>  // uint8_t, uint16_t, etc.
00009 
00010 namespace Conjecture {
00019     class Coord : public Root {
00020       public:
00021         u2 x; // horizontal pixel position
00022         u2 y; // vertical pixel position
00023 
00024         // NOTE: Intentionally not defining a default constructor.
00025         // Forces us not to be careless about initializing the
00026         // values, since <0,0> is rarely the correct value.
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; // printable representation
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 

Generated on Thu Jun 15 19:56:09 2006 for Conjecture by  doxygen 1.4.6