Add a helper for triangulating convex polygons
This commit is contained in:
parent
517f964ce7
commit
767eb786d5
1 changed files with 15 additions and 2 deletions
|
|
@ -28,11 +28,11 @@ namespace psemek::geom
|
|||
}
|
||||
|
||||
template <typename Index = std::uint32_t, typename T, std::size_t N>
|
||||
std::vector<simplex<Index, 1>> edges(box<T, N> const &)
|
||||
std::vector<segment<Index>> edges(box<T, N> const &)
|
||||
{
|
||||
static_assert(N > 0); // who knows?..
|
||||
|
||||
std::vector<simplex<Index, 1>> result;
|
||||
std::vector<segment<Index>> result;
|
||||
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
|
|
@ -51,4 +51,17 @@ namespace psemek::geom
|
|||
return result;
|
||||
}
|
||||
|
||||
template <typename Index = std::uint32_t, typename Vertex>
|
||||
std::vector<triangle<Index>> triangulate_convex(std::vector<Vertex> const & v)
|
||||
{
|
||||
std::vector<triangle<Index>> result;
|
||||
|
||||
for (std::size_t i = 1; i + 1 < v.size(); ++i)
|
||||
{
|
||||
result.push_back({static_cast<Index>(0), static_cast<Index>(i), static_cast<Index>(i + 1)});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue