00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef _TMWSERV_POINT_H_
00022 #define _TMWSERV_POINT_H_
00023
00024 #include <algorithm>
00025
00029 class Point
00030 {
00031 public:
00032 Point():
00033 x(0), y(0)
00034 {}
00035
00036 Point(unsigned short X, unsigned short Y):
00037 x(X), y(Y)
00038 {}
00039
00040 unsigned short x;
00041 unsigned short y;
00046 bool inRangeOf(const Point &p, int radius) const
00047 {
00048 return std::abs(x - p.x) <= radius &&
00049 std::abs(y - p.y) <= radius;
00050 }
00051
00052 bool operator== (const Point &other) const
00053 {
00054 return (x == other.x && y == other.y);
00055 }
00056
00057 bool operator!= (const Point &other) const
00058 {
00059 return (x != other.x || y != other.y);
00060 }
00061 };
00062
00067 class Rectangle
00068 {
00069 public:
00070 unsigned short x;
00071 unsigned short y;
00072 unsigned short w;
00073 unsigned short h;
00075 bool contains(const Point &p) const
00076 {
00077 return (unsigned short)(p.x - x) < w &&
00078 (unsigned short)(p.y - y) < h;
00079 }
00080 };
00081
00082 #endif // _TMWSERV_POINT_H_