Skip to content
Snippets Groups Projects
Commit 540f0965 authored by Dennis Gläser's avatar Dennis Gläser Committed by Timo Koch
Browse files

[grahamconvexhull] add impl for 2d hulls

This actually makes use of the 2d in 3d algorithm at the moment. In the
future a more efficient implementation for 2d hulls could be
implemented.
parent c4527cb1
No related branches found
No related tags found
1 merge request!1625Feature/2d 2d intersections
......@@ -175,6 +175,31 @@ grahamConvexHull2d3d(std::vector<Dune::FieldVector<ctype, 3>>& points)
return convexHull;
}
/*!
* \ingroup Geometry
* \brief Compute the points making up the convex hull around the given set of unordered points
* \note This is the specialization for 2d space. Here, we make use of the generic implementation
* for the case of coplanar points in 3d space (a more efficient implementation could be provided).
*/
template<class ctype>
std::vector<Dune::FieldVector<ctype, 2>>
grahamConvexHull(const std::vector<Dune::FieldVector<ctype, 2>>& points)
{
std::vector<Dune::FieldVector<ctype, 3>> tmp;
tmp.reserve(points.size());
for (const auto& p : points)
tmp.emplace_back( Dune::FieldVector<ctype, 3>({p[0], p[1], 0.0}) );
auto result3d = grahamConvexHull2d3d(tmp);
std::vector<Dune::FieldVector<ctype, 2>> result;
result.reserve(result3d.size());
for (const auto& p : result3d)
result.emplace_back( Dune::FieldVector<ctype, 2>({p[0], p[1]}) );
return result;
}
/*!
* \ingroup Geometry
* \brief Triangulate area given points of the convex hull
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment