15inline std::vector<Ring>
rings(
const std::vector<double>& x,
const std::vector<double>&
y) {
16 std::vector<Ring> out;
17 if (x.size() !=
y.size())
19 std::size_t first = 0;
20 for (std::size_t i = 1; i < x.size(); ++i) {
21 if (i - first >= 3 && x[i] == x[first] &&
y[i] ==
y[first]) {
22 out.push_back({first, i - first});
26 if (x.size() - first >= 3)
27 out.push_back({first, x.size() - first});
31inline bool contains(
const std::vector<double>& x,
const std::vector<double>&
y,
32 Ring ring,
double px,
double py) {
34 for (std::size_t i = 0, j = ring.
count - 1; i < ring.
count; j = i++) {
35 const auto a = ring.
first + i, b = ring.
first + j;
36 if ((
y[a] > py) != (
y[b] > py) &&
37 px < (x[b] - x[a]) * (py -
y[a]) / (
y[b] -
y[a]) + x[a])
43inline bool contains(
const std::vector<double>& x,
const std::vector<double>&
y,
44 double px,
double py) {
46 for (
auto ring :
rings(x,
y))
Definition PolygonRings.hpp:8
bool contains(const std::vector< double > &x, const std::vector< double > &y, Ring ring, double px, double py)
Definition PolygonRings.hpp:31
std::vector< Ring > rings(const std::vector< double > &x, const std::vector< double > &y)
Definition PolygonRings.hpp:15
double * y
Definition odesolve.c:37
Definition PolygonRings.hpp:9
std::size_t first
Definition PolygonRings.hpp:10
std::size_t count
Definition PolygonRings.hpp:10