From 2cf895daf95e07b059f81918184dda4e33d80226 Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Wed, 26 Oct 2011 22:59:47 +1100 Subject: [PATCH] Change abbreviate width/height variables --- region.cpp | 46 +++++++++++++++++++++++----------------------- region.hpp | 6 +++--- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/region.cpp b/region.cpp index 5bfcd02a..61a0f125 100644 --- a/region.cpp +++ b/region.cpp @@ -30,11 +30,11 @@ using namespace util; template -region::region (T _x, T _y, T _width, T _height): - x (_x), - y (_y), - width (_width), - height (_height) +region::region (T _x, T _y, T _w, T _h): + x (_x), + y (_y), + w (_w), + h (_h) { ; } @@ -51,13 +51,13 @@ region::operator+= (const vector &rhs) { template T region::area (void) const - { return width * height; } + { return w * h; } template T region::diameter (void) const { - return (T)sqrt (width * width + height * height); + return (T)sqrt (w * w + h * h); } @@ -77,8 +77,8 @@ region::base (void) const { template point region::centre (void) const { - double cx = x + static_cast(width / 2.0), - cy = y + static_cast(height / 2.0); + double cx = x + static_cast(w / 2.0), + cy = y + static_cast(h / 2.0); return { cx, cy, 0.0 }; } @@ -89,8 +89,8 @@ bool region::includes (const point &p) const { return p.x >= x && p.y >= y && - p.x <= x + width && - p.y <= y + height; + p.x <= x + w && + p.y <= y + h; } @@ -99,32 +99,32 @@ bool region::contains (const point& p) const { return p.x > x && p.y > y && - p.x < x + width && - p.y < y + height; + p.x < x + w && + p.y < y + h; } template bool region::overlaps (const region &rhs) const { - return x < rhs.x + rhs.width && - x + width > rhs.x && - y < rhs.y + rhs.height && - y + height > rhs.y; + return x < rhs.x + rhs.w && + x + w > rhs.x && + y < rhs.y + rhs.h && + y + h > rhs.y; } template bool region::operator ==(const region& rhs) const - { return almost_equal (x, rhs.x) && - almost_equal (y, rhs.y) && - almost_equal (width, rhs.width) && - almost_equal (height, rhs.height); } + { return almost_equal (x, rhs.x) && + almost_equal (y, rhs.y) && + almost_equal (w, rhs.w) && + almost_equal (h, rhs.h); } template void region::sanity (void) const - { check (width >= 0 && height >= 0); } + { check (w >= 0 && h >= 0); } namespace util { @@ -137,7 +137,7 @@ namespace util { template std::ostream& operator<< (std::ostream &os, const region &rhs) { - os << "region(" << rhs.x << ", " << rhs.y << ", " << rhs.width << ", " << rhs.height << ")"; + os << "region(" << rhs.x << ", " << rhs.y << ", " << rhs.w << ", " << rhs.h << ")"; return os; } diff --git a/region.hpp b/region.hpp index 4da5b181..1c0cd1ba 100644 --- a/region.hpp +++ b/region.hpp @@ -29,10 +29,10 @@ namespace util { */ template struct region { - T x, y; - T width, height; + T x, y; + T w, h; - region (T _x, T _y, T _width, T _height); + region (T _x, T _y, T _w, T _h); region& operator +=(const vector& rhs);