149 Vec2d& polygon_closest_point,
150 Vec2d& segment_closest_point)
const;
188 Vec2d& self_closest_point,
189 Vec2d& other_closest_point)
const;
239 bool check_area =
true);
260 Vec2d *
const last)
const;
345 Vec2d *
const last)
const;
373 int Next(
int at)
const;
374 int Prev(
int at)
const;
377 std::vector<Vec2d> *
const points);
Implements a class of (undirected) axes-aligned bounding boxes in 2-D.
Rectangular (undirected) bounding box in 2-D.
The class of polygon in 2-D.
std::vector< LineSegment2d > GetAllOverlaps(const LineSegment2d &line_segment) const
Get all overlapped line segments of a line segment and this polygon.
bool HasOverlap(const LineSegment2d &line_segment) const
Check if a line segment has overlap with this polygon.
std::string DebugString() const
Get a string containing essential information about the polygon for debugging purpose.
std::vector< Vec2d > points_
bool IsPointIn(const Vec2d &point) const
Check if a point is within the polygon.
static bool ComputeConvexHull(const std::vector< Vec2d > &points, Polygon2d *const polygon, bool check_area=true)
Compute the convex hull of a group of points.
bool Contains(const LineSegment2d &line_segment) const
Check if the polygon contains a line segment.
Polygon2d()=default
Empty constructor.
LineSegment2d MinLineSegment() const
Box2d BoundingBoxWithHeading(const double heading) const
Get the bound box according to a heading.
Polygon2d ExpandByDistance(const double distance) const
Expand this polygon by a distance.
Box2d MinAreaBoundingBox() const
Get the bounding box with the minimal area.
AABox2d AABoundingBox() const
Get the axis-aligned bound box of the polygon.
double DistanceTo(const Vec2d &point) const
Compute the distance from a point to the polygon.
const std::vector< LineSegment2d > & line_segments() const
Get the edges of the polygon.
void CalculateVertices(const Vec2d &shift_vec)
void ExtremePoints(const double heading, Vec2d *const first, Vec2d *const last) const
Get the extreme points along a heading direction.
bool GetOverlap(const LineSegment2d &line_segment, Vec2d *const first, Vec2d *const last) const
Get the overlap of a line segment and this polygon.
double ComputeIoU(const Polygon2d &other_polygon) const
Compute intersection over union ratio of this polygon and the other polygon.
const std::vector< Vec2d > & points() const
Get the vertices of the polygon.
double DistanceSquareTo(const Vec2d &point) const
Compute the square of distance from a point to the polygon.
void BuildFromPoints(bool check_area=true)
std::vector< Vec2d > GetAllVertices() const
Get all vertices of the polygon
std::vector< LineSegment2d > line_segments_
bool IsPointOnBoundary(const Vec2d &point) const
Check if a point is on the boundary of the polygon.
bool ComputeOverlap(const Polygon2d &other_polygon, Polygon2d *const overlap_polygon) const
Compute the overlap of this polygon and the other polygon if any.
int num_points() const
Get the number of vertices of the polygon.
Polygon2d PolygonExpandByDistance(const double distance) const
bool is_convex() const
Check if the polygon is convex.
double area() const
Get the area of the polygon.
static bool ClipConvexHull(const LineSegment2d &line_segment, std::vector< Vec2d > *const points)
double DistanceToBoundary(const Vec2d &point) const
Compute the distance from a point to the boundary of the polygon.
Implements a class of 2-dimensional vectors.
Define the LineSegment2d class.