vector: move vector::is_zero to coord::almost_zero

This commit is contained in:
Danny Robson 2016-08-11 16:32:48 +10:00
parent fe625c3441
commit 1f3b44a20e
3 changed files with 22 additions and 15 deletions

View File

@ -312,6 +312,27 @@ namespace util {
}
//-------------------------------------------------------------------------
template <
size_t S,
typename T,
template <size_t,typename> class K,
typename = std::enable_if_t<
is_coord_v<K>, void
>
>
constexpr
bool
almost_zero (const K<S,T> &k)
{
return std::all_of (
std::cbegin (k),
std::cend (k),
[] (T t) { return almost_equal (t); }
);
}
///////////////////////////////////////////////////////////////////////////
// special operators

View File

@ -154,18 +154,7 @@ util::cartesian_to_spherical (vector<3,T> c)
}
//-----------------------------------------------------------------------------
template <size_t S, typename T>
bool
util::vector<S,T>::is_zero (void) const
{
return std::all_of (std::begin (this->data),
std::end (this->data),
[] (T i) { return almost_zero (i); });
}
//-----------------------------------------------------------------------------
///////////////////////////////////////////////////////////////////////////////
template <size_t S, typename T>
const util::vector<S,T>
util::vector<S,T>::UNIT (T{1});

View File

@ -29,9 +29,6 @@ namespace util {
{
using coord::base<S,T,util::vector,coord::xyzw,coord::stpq>::base;
// vector size
bool is_zero (void) const;
T difference (vector<S,T>) const;
T difference2 (vector<S,T>) const;