Add simplex comparison operators
This commit is contained in:
parent
7ac4e3eb9b
commit
18fa286896
1 changed files with 37 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
|
||||
#include <iostream>
|
||||
#include <type_traits>
|
||||
#include <algorithm>
|
||||
|
||||
namespace psemek::geom
|
||||
{
|
||||
|
|
@ -35,6 +36,42 @@ namespace psemek::geom
|
|||
template <typename Point>
|
||||
using triangle = simplex<Point, 2>;
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator == (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return std::equal(s1.points, s1.points + K + 1, s2.points);
|
||||
}
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator != (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return !(s1 == s2);
|
||||
}
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator < (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return std::lexicographical_compare(s1.points, s1.points + K + 1, s2.points, s2.points + K + 1);
|
||||
}
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator > (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return s2 < s1;
|
||||
}
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator <= (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return !(s2 < s1);
|
||||
}
|
||||
|
||||
template <typename P, std::size_t K>
|
||||
bool operator >= (simplex<P, K> const & s1, simplex<P, K> const & s2)
|
||||
{
|
||||
return !(s1 < s2);
|
||||
}
|
||||
|
||||
template <typename Point, std::size_t K>
|
||||
std::ostream & operator << (std::ostream & os, simplex<Point, K> const & s)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue