Add diameter methods to region and extent
This commit is contained in:
parent
1c73bddf8b
commit
020a3a4afe
15
region.cpp
15
region.cpp
@ -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
|
||||
|
@ -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;
|
||||
@ -55,7 +57,10 @@ namespace util {
|
||||
region (T _x, T _y, T _width, T _height);
|
||||
|
||||
T area (void) const;
|
||||
T diameter (void) const;
|
||||
|
||||
bool empty (void) const;
|
||||
|
||||
point centre (void) const;
|
||||
|
||||
bool includes (const point&) const; // inclusive of borders
|
||||
|
Loading…
Reference in New Issue
Block a user