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 "enable_if.hpp"
|
||||||
#include "debug.hpp"
|
#include "debug.hpp"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
|
||||||
using namespace util;
|
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>
|
template <typename T>
|
||||||
T
|
T
|
||||||
extent<T>::area (void) const
|
extent<T>::area (void) const
|
||||||
@ -92,6 +100,13 @@ region<T>::area (void) const
|
|||||||
{ return width * height; }
|
{ return width * height; }
|
||||||
|
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T
|
||||||
|
region<T>::diameter (void) const {
|
||||||
|
return (T)sqrt (width * width + height * height);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
bool
|
bool
|
||||||
region<T>::empty (void) const
|
region<T>::empty (void) const
|
||||||
|
@ -34,6 +34,8 @@ namespace util {
|
|||||||
extent (const T _width, const T _height);
|
extent (const T _width, const T _height);
|
||||||
|
|
||||||
T area (void) const;
|
T area (void) const;
|
||||||
|
T diameter (void) const;
|
||||||
|
|
||||||
bool empty (void) const;
|
bool empty (void) const;
|
||||||
|
|
||||||
bool operator ==(const extent& rhs) const;
|
bool operator ==(const extent& rhs) const;
|
||||||
@ -54,8 +56,11 @@ namespace util {
|
|||||||
|
|
||||||
region (T _x, T _y, T _width, T _height);
|
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;
|
bool empty (void) const;
|
||||||
|
|
||||||
point centre (void) const;
|
point centre (void) const;
|
||||||
|
|
||||||
bool includes (const point&) const; // inclusive of borders
|
bool includes (const point&) const; // inclusive of borders
|
||||||
|
Loading…
Reference in New Issue
Block a user