MCPcopy Create free account
hub / github.com/ANYbotics/grid_map / isInside

Method isInside

grid_map_core/src/Polygon.cpp:32–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30Polygon::~Polygon() {}
31
32bool Polygon::isInside(const Position& point) const
33{
34 int cross = 0;
35 for (int i = 0, j = vertices_.size() - 1; i < vertices_.size(); j = i++) {
36 if ( ((vertices_[i].y() > point.y()) != (vertices_[j].y() > point.y()))
37 && (point.x() < (vertices_[j].x() - vertices_[i].x()) * (point.y() - vertices_[i].y()) /
38 (vertices_[j].y() - vertices_[i].y()) + vertices_[i].x()) )
39 {
40 cross++;
41 }
42 }
43 return bool(cross % 2);
44}
45
46void Polygon::addVertex(const Position& vertex)
47{

Callers 5

mainFunction · 0.45
mapAddOutliersFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45
TESTFunction · 0.45

Calls

no outgoing calls

Tested by 3

TESTFunction · 0.36
TESTFunction · 0.36
TESTFunction · 0.36