23#ifndef VCL_ALGORITHMS_CORE_POLYGON_CONVEX_HULL_H
24#define VCL_ALGORITHMS_CORE_POLYGON_CONVEX_HULL_H
38template<Po
int2IteratorConcept InputIterator,
typename OutputContainer>
39void grahamScanOnContainer(
40 const InputIterator first,
41 const InputIterator end,
42 OutputContainer& outContainer)
52 std::vector<InputIterator> stack;
59 assert(std::next(first) != end);
60 assert(*first != *last);
63 stack.push_back(last);
64 stack.push_back(first);
83 typename std::vector<InputIterator>::reverse_iterator stackItR =
89 for (it1++; it1 != last; it1++) {
100 stackItR = stack.rbegin();
105 assert(stack.size() >= 2);
109 stack.push_back(it1);
117 typename std::vector<InputIterator>::iterator sIter = stack.begin();
118 for (++sIter; sIter != stack.end(); ++sIter) {
119 outContainer.pushBack(**sIter);
136template<Po
int2IteratorConcept InputIterator>
139 using PointType = std::decay_t<
decltype(*first)>;
159 detail::grahamScanOnContainer(
161 detail::grahamScanOnContainer(
171template<Range InputContainer>
172auto convexHull(
const InputContainer& container)
173 requires Point2Concept<std::ranges::range_value_t<InputContainer>>
175 return convexHull(container.begin(), container.end());
A class representing a line segment in n-dimensional space. The class is parameterized by a PointConc...
Definition segment.h:43
auto convexHull(InputIterator first, InputIterator end)
Get the 2D convex hull using Graham scan algorithm on a set of points.
Definition convex_hull.h:137
bool areCounterClockwise(const PointType &p0, const PointType &p1, const PointType &p2)
Checks if the three points are counter-clockwise.
Definition core2.h:75