5 #define ABS(x) ( x>0 ? x : -x )
12 ePoint( int xpos, int ypos );
21 int manhattanLength() const;
26 ePoint &operator+=( const ePoint &p );
27 ePoint &operator-=( const ePoint &p );
28 ePoint &operator*=( int c );
29 ePoint &operator*=( double c );
30 ePoint &operator/=( int c );
31 ePoint &operator/=( double c );
33 friend inline bool operator==( const ePoint &, const ePoint & );
34 friend inline bool operator!=( const ePoint &, const ePoint & );
35 friend inline ePoint operator+( const ePoint &, const ePoint & );
36 friend inline ePoint operator+( const ePoint &, const eSize & );
37 friend inline ePoint operator-( const ePoint &, const ePoint & );
38 friend inline ePoint operator-( const ePoint &, const eSize & );
39 friend inline ePoint operator*( const ePoint &, int );
40 friend inline ePoint operator*( int, const ePoint & );
41 friend inline ePoint operator*( const ePoint &, double );
42 friend inline ePoint operator*( double, const ePoint & );
43 friend inline ePoint operator-( const ePoint & );
44 friend inline ePoint operator/( const ePoint &, int );
45 friend inline ePoint operator/( const ePoint &, double );
52 inline int ePoint::manhattanLength() const
54 return ABS(x())+ABS(y());
58 /*****************************************************************************
59 ePoint inline functions
60 *****************************************************************************/
62 inline ePoint::ePoint()
65 inline ePoint::ePoint( int xpos, int ypos )
66 { xp=(int)xpos; yp=(int)ypos; }
68 inline bool ePoint::isNull() const
69 { return xp == 0 && yp == 0; }
71 inline int ePoint::x() const
74 inline int ePoint::y() const
77 inline void ePoint::setX( int x )
80 inline void ePoint::setY( int y )
83 inline int &ePoint::rx()
86 inline int &ePoint::ry()
89 inline ePoint &ePoint::operator+=( const ePoint &p )
90 { xp+=p.xp; yp+=p.yp; return *this; }
92 inline ePoint &ePoint::operator-=( const ePoint &p )
93 { xp-=p.xp; yp-=p.yp; return *this; }
95 inline ePoint &ePoint::operator*=( int c )
96 { xp*=(int)c; yp*=(int)c; return *this; }
98 inline ePoint &ePoint::operator*=( double c )
99 { xp=(int)(xp*c); yp=(int)(yp*c); return *this; }
101 inline bool operator==( const ePoint &p1, const ePoint &p2 )
102 { return p1.xp == p2.xp && p1.yp == p2.yp; }
104 inline bool operator!=( const ePoint &p1, const ePoint &p2 )
105 { return p1.xp != p2.xp || p1.yp != p2.yp; }
107 inline ePoint operator+( const ePoint &p1, const ePoint &p2 )
108 { return ePoint(p1.xp+p2.xp, p1.yp+p2.yp); }
110 inline ePoint operator-( const ePoint &p1, const ePoint &p2 )
111 { return ePoint(p1.xp-p2.xp, p1.yp-p2.yp); }
113 inline ePoint operator+( const ePoint &p1, const eSize &p2 )
114 { return ePoint(p1.xp+p2.width(), p1.yp+p2.height()); }
116 inline ePoint operator-( const ePoint &p1, const eSize &p2 )
117 { return ePoint(p1.xp-p2.width(), p1.yp-p2.height()); }
119 inline ePoint operator*( const ePoint &p, int c )
120 { return ePoint(p.xp*c, p.yp*c); }
122 inline ePoint operator*( int c, const ePoint &p )
123 { return ePoint(p.xp*c, p.yp*c); }
125 inline ePoint operator*( const ePoint &p, double c )
126 { return ePoint((int)(p.xp*c), (int)(p.yp*c)); }
128 inline ePoint operator*( double c, const ePoint &p )
129 { return ePoint((int)(p.xp*c), (int)(p.yp*c)); }
131 inline ePoint operator-( const ePoint &p )
132 { return ePoint(-p.xp, -p.yp); }
134 inline ePoint &ePoint::operator/=( int c )
141 inline ePoint &ePoint::operator/=( double c )
148 inline ePoint operator/( const ePoint &p, int c )
150 return ePoint(p.xp/c, p.yp/c);
153 inline ePoint operator/( const ePoint &p, double c )
155 return ePoint((int)(p.xp/c), (int)(p.yp/c));