Change abbreviate width/height variables

This commit is contained in:
Danny Robson 2011-10-26 22:59:47 +11:00
parent aba0611567
commit 2cf895daf9
2 changed files with 26 additions and 26 deletions

View File

@ -30,11 +30,11 @@ using namespace util;
template <typename T> template <typename T>
region<T>::region (T _x, T _y, T _width, T _height): region<T>::region (T _x, T _y, T _w, T _h):
x (_x), x (_x),
y (_y), y (_y),
width (_width), w (_w),
height (_height) h (_h)
{ ; } { ; }
@ -51,13 +51,13 @@ region<T>::operator+= (const vector &rhs) {
template <typename T> template <typename T>
T T
region<T>::area (void) const region<T>::area (void) const
{ return width * height; } { return w * h; }
template <typename T> template <typename T>
T T
region<T>::diameter (void) const { region<T>::diameter (void) const {
return (T)sqrt (width * width + height * height); return (T)sqrt (w * w + h * h);
} }
@ -77,8 +77,8 @@ region<T>::base (void) const {
template <typename T> template <typename T>
point point
region<T>::centre (void) const { region<T>::centre (void) const {
double cx = x + static_cast<T>(width / 2.0), double cx = x + static_cast<T>(w / 2.0),
cy = y + static_cast<T>(height / 2.0); cy = y + static_cast<T>(h / 2.0);
return { cx, cy, 0.0 }; return { cx, cy, 0.0 };
} }
@ -89,8 +89,8 @@ bool
region<T>::includes (const point &p) const { region<T>::includes (const point &p) const {
return p.x >= x && return p.x >= x &&
p.y >= y && p.y >= y &&
p.x <= x + width && p.x <= x + w &&
p.y <= y + height; p.y <= y + h;
} }
@ -99,32 +99,32 @@ bool
region<T>::contains (const point& p) const { region<T>::contains (const point& p) const {
return p.x > x && return p.x > x &&
p.y > y && p.y > y &&
p.x < x + width && p.x < x + w &&
p.y < y + height; p.y < y + h;
} }
template <typename T> template <typename T>
bool bool
region<T>::overlaps (const region<T> &rhs) const { region<T>::overlaps (const region<T> &rhs) const {
return x < rhs.x + rhs.width && return x < rhs.x + rhs.w &&
x + width > rhs.x && x + w > rhs.x &&
y < rhs.y + rhs.height && y < rhs.y + rhs.h &&
y + height > rhs.y; y + h > rhs.y;
} }
template <typename T> template <typename T>
bool bool
region<T>::operator ==(const region& rhs) const region<T>::operator ==(const region& rhs) const
{ return almost_equal (x, rhs.x) && { return almost_equal (x, rhs.x) &&
almost_equal (y, rhs.y) && almost_equal (y, rhs.y) &&
almost_equal (width, rhs.width) && almost_equal (w, rhs.w) &&
almost_equal (height, rhs.height); } almost_equal (h, rhs.h); }
template <typename T> template <typename T>
void region<T>::sanity (void) const void region<T>::sanity (void) const
{ check (width >= 0 && height >= 0); } { check (w >= 0 && h >= 0); }
namespace util { namespace util {
@ -137,7 +137,7 @@ namespace util {
template <typename T> template <typename T>
std::ostream& std::ostream&
operator<< (std::ostream &os, const region<T> &rhs) { operator<< (std::ostream &os, const region<T> &rhs) {
os << "region(" << rhs.x << ", " << rhs.y << ", " << rhs.width << ", " << rhs.height << ")"; os << "region(" << rhs.x << ", " << rhs.y << ", " << rhs.w << ", " << rhs.h << ")";
return os; return os;
} }

View File

@ -29,10 +29,10 @@ namespace util {
*/ */
template <typename T> template <typename T>
struct region { struct region {
T x, y; T x, y;
T width, height; 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); region& operator +=(const vector& rhs);