diff options
-rw-r--r-- | crawl-ref/source/coord-circle.cc | 15 | ||||
-rw-r--r-- | crawl-ref/source/coord-circle.h | 5 |
2 files changed, 20 insertions, 0 deletions
diff --git a/crawl-ref/source/coord-circle.cc b/crawl-ref/source/coord-circle.cc index 8580313e01..135924e33f 100644 --- a/crawl-ref/source/coord-circle.cc +++ b/crawl-ref/source/coord-circle.cc @@ -6,6 +6,21 @@ #include <cmath> +bool rect_def::contains(const coord_def& p) const +{ + return (p.x >= min.x && p.x <= max.x && p.y >= min.y && p.y <= max.y); +} + +rect_def rect_def::intersect(const rect_def& other) const +{ + rect_def res; + res.min.x = std::max(min.x, other.min.x); + res.min.y = std::max(min.y, other.min.y); + res.max.x = std::min(max.x, other.max.x); + res.max.y = std::min(max.y, other.max.y); + return (res); +} + rectangle_iterator rect_def::iter() const { return (rectangle_iterator(min, max)); diff --git a/crawl-ref/source/coord-circle.h b/crawl-ref/source/coord-circle.h index 9cf52acbe8..9a8dc088d2 100644 --- a/crawl-ref/source/coord-circle.h +++ b/crawl-ref/source/coord-circle.h @@ -26,9 +26,14 @@ public: rect_def(const coord_def &min_, const coord_def &max_) : min(min_), max(max_) {} + bool contains(const coord_def& p) const; + rect_def intersect(const rect_def& other) const; rectangle_iterator iter() const; }; +#define RECT_MAP_BOUNDS (rect_def(coord_def(X_BOUND_1, Y_BOUND_1), \ + coord_def(X_BOUND_2, Y_BOUND_2))) + class circle_iterator; class circle_def { |