Coord.h

00001 # ifndef Coord_h
00002 # define Coord_h Coord_h
00003 
00004 # include "Root.h"
00005 # include <stdint.h>  // uint8_t, uint16_t, etc.
00006 
00007 namespace Conjecture {
00016     class Coord : public Root {
00017       public:
00018         u2 x; // horizontal pixel position
00019         u2 y; // vertical pixel position
00020 
00021         // NOTE: Intentionally not defining a default constructor.
00022         // Forces us not to be careless about initializing the
00023         // values, since <0,0> is rarely the correct value.
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; // printable representation
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 

Generated on Wed Jun 14 15:08:02 2006 for Conjecture by  doxygen 1.4.6