hex::Point Struct Reference

#include <hex.h>

List of all members.


Detailed Description

X-Y coordinate.

Definition at line 174 of file hex.h.

Public Member Functions

Point offset (Distance dx, Distance dy) const
 Point ()
 Point (Distance x_, Distance y_)
 Point (const std::string s) throw (out_of_range,invalid_argument)
Pointoperator+= (const Point &p)
Pointoperator-= (const Point &p)
Point operator+ (const Point &p) const
Point operator- (const Point &p) const
Point operator * (double v) const
Point operator/ (double v) const
bool operator== (const Point &p) const
bool operator!= (const Point &p) const
std::string str (void) const

Public Attributes

Distance x
Distance y


Constructor & Destructor Documentation

hex::Point::Point (  )  [inline]

Definition at line 178 of file hex.h.

00178 : x(0.0), y(0.0) {}

hex::Point::Point ( Distance  x_,
Distance  y_ 
) [inline]

Definition at line 179 of file hex.h.

00179 : x(x_), y(y_) {}

hex::Point::Point ( const std::string  s  )  throw (out_of_range,invalid_argument)

Definition at line 38 of file grid.cc.

00039 {
00040   // Parse strings like: / *[-+]?\d+_ *[-+]?\d+([^\d].*)?/
00041   // E.g.  '1_2' ' +2_ 4' '2_4 # comment'
00042   const char* buf =s.c_str();
00043   char* endptr =NULL;
00044   errno=0;
00045   this->x = ::strtod(buf,&endptr);
00046   if(endptr==buf || *endptr!=',')
00047       throw hex::invalid_argument(s);
00048   buf =endptr+1;
00049   this->y = ::strtod(buf,&endptr);
00050   if(endptr==buf)
00051       throw hex::invalid_argument(s);
00052   if(ERANGE==errno)
00053       throw hex::out_of_range(s);
00054 }


Member Function Documentation

Point hex::Point::offset ( Distance  dx,
Distance  dy 
) const [inline]

Definition at line 177 of file hex.h.

Referenced by hex::corner_offset().

00177 { return Point(x+dx,y+dy); }

Point& hex::Point::operator+= ( const Point p  )  [inline]

Definition at line 181 of file hex.h.

References x, and y.

00181 { x+=p.x; y+=p.y; return *this; }

Point& hex::Point::operator-= ( const Point p  )  [inline]

Definition at line 182 of file hex.h.

References x, and y.

00182 { x-=p.x; y-=p.y; return *this; }

Point hex::Point::operator+ ( const Point p  )  const [inline]

Definition at line 183 of file hex.h.

References x, and y.

00183 { return Point(x+p.x,y+p.y); }

Point hex::Point::operator- ( const Point p  )  const [inline]

Definition at line 184 of file hex.h.

References x, and y.

00184 { return Point(x-p.x,y-p.y); }

Point hex::Point::operator * ( double  v  )  const [inline]

Definition at line 185 of file hex.h.

00185 { return Point(x*v,y*v); }

Point hex::Point::operator/ ( double  v  )  const [inline]

Definition at line 186 of file hex.h.

00186 { return Point(x/v,y/v); }

bool hex::Point::operator== ( const Point p  )  const [inline]

Definition at line 187 of file hex.h.

References x, and y.

00187 { return(x==p.x && y==p.y); }

bool hex::Point::operator!= ( const Point p  )  const [inline]

Definition at line 188 of file hex.h.

00188 { return !operator==(p); }

std::string hex::Point::str ( void   )  const

Definition at line 58 of file grid.cc.

References x, and y.

Referenced by hex::svg::path_append().

00059 {
00060   std::ostringstream ss;
00061   ss<< this->x << "," << this->y;
00062   return ss.str();
00063 }


Member Data Documentation

Distance hex::Point::x

Definition at line 176 of file hex.h.

Referenced by hex::Hex::centre(), hex::move::_Route::distance(), hex::svg::Document::header(), operator+(), operator+=(), operator-(), operator-=(), hex::svg::operator<<(), operator==(), str(), and hex::svg::Document::T().

Distance hex::Point::y

Definition at line 176 of file hex.h.

Referenced by hex::Hex::centre(), hex::move::_Route::distance(), hex::svg::Document::header(), operator+(), operator+=(), operator-(), operator-=(), hex::svg::operator<<(), operator==(), str(), and hex::svg::Document::T().


The documentation for this struct was generated from the following files:
Generated on Thu Feb 21 00:00:55 2008 for libhex by  doxygen 1.5.1