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