46 lines
852 B
C++
46 lines
852 B
C++
#pragma once
|
|
|
|
#include <psemek/geom/point.hpp>
|
|
|
|
#include <type_traits>
|
|
|
|
namespace psemek::geom
|
|
{
|
|
|
|
template <typename Point, std::size_t K>
|
|
struct simplex
|
|
{
|
|
using point_type = Point;
|
|
|
|
point_type points[K + 1];
|
|
|
|
point_type & operator[](std::size_t i)
|
|
{
|
|
return points[i];
|
|
}
|
|
|
|
point_type const & operator[](std::size_t i) const
|
|
{
|
|
return points[i];
|
|
}
|
|
};
|
|
|
|
template <typename ... Args>
|
|
simplex(Args ...) -> simplex<std::common_type_t<Args...>, sizeof...(Args) - 1>;
|
|
|
|
template <typename Point>
|
|
using segment = simplex<Point, 1>;
|
|
|
|
template <typename Point>
|
|
using triangle = simplex<Point, 2>;
|
|
|
|
template <typename Stream, typename Point, std::size_t K>
|
|
Stream & operator << (Stream & os, simplex<Point, K> const & s)
|
|
{
|
|
os << '(' << s[0];
|
|
for (std::size_t i = 1; i <= K; ++i)
|
|
os << ", " << s[i];
|
|
return os << ')';
|
|
}
|
|
|
|
}
|