30 #ifndef COSTMAP_CSPACE_POLYGON_H 31 #define COSTMAP_CSPACE_POLYGON_H 63 return (*
this)[0] * a[1] - (*this)[1] * a[0];
67 return (*
this)[0] * a[0] + (*this)[1] * a[1];
71 return hypotf((*
this)[0] - a[0], (*
this)[1] - a[1]);
75 return (b - a).cross((*
this) - a) / b.
dist(a);
79 if ((b - a).
dot((*
this) - a) <= 0)
81 if ((a - b).
dot((*
this) - b) <= 0)
99 throw std::runtime_error(
"Invalid footprint xml.");
102 for (
int i = 0; i < footprint_xml.
size(); i++)
107 p[0] =
static_cast<double>(footprint_xml[i][0]);
108 p[1] =
static_cast<double>(footprint_xml[i][1]);
112 throw std::runtime_error((
"Invalid footprint xml." + e.
getMessage()).c_str());
117 v.push_back(v.front());
119 geometry_msgs::PolygonStamped
toMsg()
const 121 geometry_msgs::PolygonStamped msg;
123 msg.polygon.points.clear();
124 msg.header.frame_id =
"base_link";
125 for (
const auto& p : v)
127 geometry_msgs::Point32 point;
131 msg.polygon.points.push_back(point);
133 msg.polygon.points.push_back(msg.polygon.points[0]);
140 for (
const auto& p : v)
142 const auto dist = hypotf(p[0], p[1]);
148 void move(
const float& x,
const float& y,
const float& yaw)
150 float cos_v = cosf(yaw);
151 float sin_v = sinf(yaw);
155 p[0] = cos_v * tmp[0] - sin_v * tmp[1] + x;
156 p[1] = sin_v * tmp[0] + cos_v * tmp[1] + y;
162 for (
size_t i = 0; i < v.size() - 1; i++)
166 if ((v1[1] <= a[1] && a[1] < v2[1]) ||
167 (v2[1] <= a[1] && a[1] < v1[1]))
170 lx = v1[0] + (v2[0] - v1[0]) * (a[1] - v1[1]) / (v2[1] - v1[1]);
175 return ((cn & 1) == 1);
179 float dist = FLT_MAX;
180 for (
size_t i = 0; i < v.size() - 1; i++)
193 #endif // COSTMAP_CSPACE_POLYGON_H Polygon(const XmlRpc::XmlRpcValue footprint_xml_const)
float dist_linestrip(const Vec &a, const Vec &b) const
const std::string & getMessage() const
float dot(const Vec &a) const
float cross(const Vec &a) const
void move(const float &x, const float &y, const float &yaw)
geometry_msgs::PolygonStamped toMsg() const
Type const & getType() const
const float & operator[](const int &i) const
bool inside(const Vec &a) const
float & operator[](const int &i)
float dist(const Vec &a) const
float dist(const Vec &a) const
float dist_line(const Vec &a, const Vec &b) const
Vec operator-(const Vec &a) const