Apollo
6.0
Open source self driving car software
|
Rectangular (undirected) bounding box in 2-D. More...
#include <box2d.h>
Public Member Functions | |
Box2d ()=default | |
Box2d (const Vec2d ¢er, const double heading, const double length, const double width) | |
Constructor which takes the center, heading, length and width. More... | |
Box2d (const LineSegment2d &axis, const double width) | |
Constructor which takes the heading-axis and the width of the box. More... | |
Box2d (const AABox2d &aabox) | |
Constructor which takes an AABox2d (axes-aligned box). More... | |
const Vec2d & | center () const |
Getter of the center of the box. More... | |
double | center_x () const |
Getter of the x-coordinate of the center of the box. More... | |
double | center_y () const |
Getter of the y-coordinate of the center of the box. More... | |
double | length () const |
Getter of the length. More... | |
double | width () const |
Getter of the width. More... | |
double | half_length () const |
Getter of half the length. More... | |
double | half_width () const |
Getter of half the width. More... | |
double | heading () const |
Getter of the heading. More... | |
double | cos_heading () const |
Getter of the cosine of the heading. More... | |
double | sin_heading () const |
Getter of the sine of the heading. More... | |
double | area () const |
Getter of the area of the box. More... | |
double | diagonal () const |
Getter of the size of the diagonal of the box. More... | |
void | GetAllCorners (std::vector< Vec2d > *const corners) const |
Getter of the corners of the box. More... | |
std::vector< Vec2d > | GetAllCorners () const |
Getter of the corners of the box. More... | |
bool | IsPointIn (const Vec2d &point) const |
Tests points for membership in the box. More... | |
bool | IsPointOnBoundary (const Vec2d &point) const |
Tests points for membership in the boundary of the box. More... | |
double | DistanceTo (const Vec2d &point) const |
Determines the distance between the box and a given point. More... | |
double | DistanceTo (const LineSegment2d &line_segment) const |
Determines the distance between the box and a given line segment. More... | |
double | DistanceTo (const Box2d &box) const |
Determines the distance between two boxes. More... | |
bool | HasOverlap (const LineSegment2d &line_segment) const |
Determines whether this box overlaps a given line segment. More... | |
bool | HasOverlap (const Box2d &box) const |
Determines whether these two boxes overlap. More... | |
AABox2d | GetAABox () const |
Gets the smallest axes-aligned box containing the current one. More... | |
void | RotateFromCenter (const double rotate_angle) |
Rotate from center. More... | |
void | Shift (const Vec2d &shift_vec) |
Shifts this box by a given vector. More... | |
void | LongitudinalExtend (const double extension_length) |
Extend the box longitudinally. More... | |
void | LateralExtend (const double extension_length) |
std::string | DebugString () const |
Gets a human-readable description of the box. More... | |
void | InitCorners () |
double | max_x () const |
double | min_x () const |
double | max_y () const |
double | min_y () const |
Static Public Member Functions | |
static Box2d | CreateAABox (const Vec2d &one_corner, const Vec2d &opposite_corner) |
Creates an axes-aligned Box2d from two opposite corners. More... | |
Rectangular (undirected) bounding box in 2-D.
This class is referential-agnostic, although our convention on the use of the word "heading" in this project (permanently set to be 0 at East) forces us to assume that the X/Y frame here is East/North. For disambiguation, we call the axis of the rectangle parallel to the heading direction the "heading-axis". The size of the heading-axis is called "length", and the size of the axis perpendicular to it "width".
|
default |
apollo::common::math::Box2d::Box2d | ( | const Vec2d & | center, |
const double | heading, | ||
const double | length, | ||
const double | width | ||
) |
Constructor which takes the center, heading, length and width.
center | The center of the rectangular bounding box. |
heading | The angle between the x-axis and the heading-axis, measured counter-clockwise. |
length | The size of the heading-axis. |
width | The size of the axis perpendicular to the heading-axis. |
apollo::common::math::Box2d::Box2d | ( | const LineSegment2d & | axis, |
const double | width | ||
) |
Constructor which takes the heading-axis and the width of the box.
axis | The heading-axis |
width | The width of the box, which is taken perpendicularly to the heading direction. |
|
explicit |
|
inline |
Getter of the area of the box.
|
inline |
Getter of the center of the box.
|
inline |
Getter of the x-coordinate of the center of the box.
|
inline |
Getter of the y-coordinate of the center of the box.
|
inline |
Getter of the cosine of the heading.
std::string apollo::common::math::Box2d::DebugString | ( | ) | const |
Gets a human-readable description of the box.
|
inline |
Getter of the size of the diagonal of the box.
double apollo::common::math::Box2d::DistanceTo | ( | const Vec2d & | point | ) | const |
Determines the distance between the box and a given point.
point | The point whose distance to the box we wish to compute |
double apollo::common::math::Box2d::DistanceTo | ( | const LineSegment2d & | line_segment | ) | const |
Determines the distance between the box and a given line segment.
line_segment | The line segment whose distance to the box we compute |
double apollo::common::math::Box2d::DistanceTo | ( | const Box2d & | box | ) | const |
Determines the distance between two boxes.
box | The box whose distance to this box we want to compute |
AABox2d apollo::common::math::Box2d::GetAABox | ( | ) | const |
Gets the smallest axes-aligned box containing the current one.
void apollo::common::math::Box2d::GetAllCorners | ( | std::vector< Vec2d > *const | corners | ) | const |
Getter of the corners of the box.
corners | The vector where the corners are listed |
std::vector<Vec2d> apollo::common::math::Box2d::GetAllCorners | ( | ) | const |
Getter of the corners of the box.
corners | The vector where the corners are listed |
|
inline |
Getter of half the length.
|
inline |
Getter of half the width.
bool apollo::common::math::Box2d::HasOverlap | ( | const LineSegment2d & | line_segment | ) | const |
Determines whether this box overlaps a given line segment.
line_segment | The line-segment |
bool apollo::common::math::Box2d::HasOverlap | ( | const Box2d & | box | ) | const |
Determines whether these two boxes overlap.
line_segment | The other box |
|
inline |
Getter of the heading.
void apollo::common::math::Box2d::InitCorners | ( | ) |
bool apollo::common::math::Box2d::IsPointIn | ( | const Vec2d & | point | ) | const |
Tests points for membership in the box.
point | A point that we wish to test for membership in the box |
bool apollo::common::math::Box2d::IsPointOnBoundary | ( | const Vec2d & | point | ) | const |
Tests points for membership in the boundary of the box.
point | A point that we wish to test for membership in the boundary |
void apollo::common::math::Box2d::LateralExtend | ( | const double | extension_length | ) |
|
inline |
Getter of the length.
void apollo::common::math::Box2d::LongitudinalExtend | ( | const double | extension_length | ) |
Extend the box longitudinally.
extension_length | the length to extend |
|
inline |
|
inline |
|
inline |
|
inline |
void apollo::common::math::Box2d::RotateFromCenter | ( | const double | rotate_angle | ) |
Rotate from center.
rotate_angle | Angle to rotate. |
void apollo::common::math::Box2d::Shift | ( | const Vec2d & | shift_vec | ) |
Shifts this box by a given vector.
shift_vec | The vector determining the shift |
|
inline |
Getter of the sine of the heading.
|
inline |
Getter of the width.