Add diameter methods to region and extent

This commit is contained in:
Danny Robson 2011-10-24 19:55:51 +11:00
parent 1c73bddf8b
commit 020a3a4afe
2 changed files with 21 additions and 1 deletions

View File

@ -23,6 +23,7 @@
#include "enable_if.hpp"
#include "debug.hpp"
#include <cmath>
#include <type_traits>
using namespace util;
@ -37,6 +38,13 @@ extent<T>::extent (const T _width, const T _height):
{ ; }
template <typename T>
T
extent<T>::diameter (void) const {
return (T)sqrt (width * width + height * height);
}
template <typename T>
T
extent<T>::area (void) const
@ -92,6 +100,13 @@ region<T>::area (void) const
{ return width * height; }
template <typename T>
T
region<T>::diameter (void) const {
return (T)sqrt (width * width + height * height);
}
template <typename T>
bool
region<T>::empty (void) const

View File

@ -34,6 +34,8 @@ namespace util {
extent (const T _width, const T _height);
T area (void) const;
T diameter (void) const;
bool empty (void) const;
bool operator ==(const extent& rhs) const;
@ -54,8 +56,11 @@ namespace util {
region (T _x, T _y, T _width, T _height);
T area (void) const;
T area (void) const;
T diameter (void) const;
bool empty (void) const;
point centre (void) const;
bool includes (const point&) const; // inclusive of borders