Recti 1.2.4
Loading...
Searching...
No Matches
rpolygon_hull.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include <functional>
8#include <span>
9#include <vector>
10
11#include "point.hpp"
12
13namespace recti {
23 template <typename T>
24 auto rpolygon_make_monotone_hull(std::span<const Point<T>> pointset, bool is_anticlockwise,
25 const std::function<std::pair<T, T>(const Point<T>&)>& dir)
26 -> std::vector<Point<T>>;
27
36 template <typename T>
37 inline auto rpolygon_make_xmonotone_hull(std::span<const Point<T>> pointset,
38 bool is_anticlockwise) -> std::vector<Point<T>> {
39 return rpolygon_make_monotone_hull<T>(pointset, is_anticlockwise, [](const Point<T>& p) {
40 return std::make_pair(p.xcoord(), p.ycoord());
41 });
42 }
43
52 template <typename T>
53 inline auto rpolygon_make_ymonotone_hull(std::span<const Point<T>> pointset,
54 bool is_anticlockwise) -> std::vector<Point<T>> {
55 return rpolygon_make_monotone_hull<T>(pointset, is_anticlockwise, [](const Point<T>& p) {
56 return std::make_pair(p.ycoord(), p.xcoord());
57 });
58 }
59
68 template <typename T>
69 inline auto rpolygon_make_convex_hull(std::span<const Point<T>> pointset, bool is_anticlockwise)
70 -> std::vector<Point<T>> {
71 auto xmono_hull = rpolygon_make_xmonotone_hull<T>(pointset, is_anticlockwise);
72 return rpolygon_make_ymonotone_hull<T>(xmono_hull, is_anticlockwise);
73 }
74} // namespace recti
Point.
Definition point.hpp:30
constexpr auto xcoord() const -> const T1 &
Gets the x coordinate of this Point.
Definition point.hpp:72
constexpr auto ycoord() const -> const T2 &
Gets the y coordinate of this Point.
Definition point.hpp:78
Definition svg_utils.hpp:12
auto rpolygon_make_convex_hull(std::span< const Point< T > > pointset, bool is_anticlockwise) -> std::vector< Point< T > >
Create a convex hull from a rectilinear polygon.
Definition rpolygon_hull.hpp:69
auto rpolygon_make_xmonotone_hull(std::span< const Point< T > > pointset, bool is_anticlockwise) -> std::vector< Point< T > >
Create an x-monotone hull from a rectilinear polygon.
Definition rpolygon_hull.hpp:37
auto rpolygon_make_monotone_hull(std::span< const Point< T > > pointset, bool is_anticlockwise, const std::function< std::pair< T, T >(const Point< T > &)> &dir) -> std::vector< Point< T > >
Create a monotone hull from a rectilinear polygon with custom direction.
auto rpolygon_make_ymonotone_hull(std::span< const Point< T > > pointset, bool is_anticlockwise) -> std::vector< Point< T > >
Create a y-monotone hull from a rectilinear polygon.
Definition rpolygon_hull.hpp:53
2D Point template class supporting intervals, arithmetic, and geometric queries.