extent: add a point inclusion query
This commit is contained in:
parent
4fad54f0b0
commit
118d1accce
@ -19,6 +19,8 @@
|
||||
|
||||
#include "coord.hpp"
|
||||
#include "vector.hpp"
|
||||
#include "point.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
|
||||
@ -40,6 +42,9 @@ namespace util {
|
||||
template <typename U = float>
|
||||
U aspect (void) const;
|
||||
|
||||
template <typename U>
|
||||
bool includes (util::point<S,U>) const;
|
||||
|
||||
extent expanded (vector<S,T>) const;
|
||||
extent expanded (T) const;
|
||||
extent contracted (vector<S,T>) const;
|
||||
|
15
extent.ipp
15
extent.ipp
@ -24,7 +24,7 @@
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
template <typename U>
|
||||
U
|
||||
@ -32,3 +32,16 @@ util::extent<S,T>::aspect (void) const
|
||||
{
|
||||
return static_cast<U> (this->w) / this->h;
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
template <size_t S, typename T>
|
||||
template <typename U>
|
||||
bool
|
||||
util::extent<S,T>::includes (point<S,U> p) const
|
||||
{
|
||||
for (size_t i = 0; i < S; ++i)
|
||||
if (p[i] < 0 || static_cast<T> (p[i]) >= this->data[i])
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user