Apollo 10.0
自动驾驶开放平台
|
Rectangular (undirected) bounding box in 2-D. 更多...
#include <box2d.h>
Public 成员函数 | |
Box2d ()=default | |
Box2d (const Vec2d ¢er, const double heading, const double length, const double width) | |
Constructor which takes the center, heading, length and width. | |
Box2d (const Vec2d &point, double heading, double front_length, double back_length, double width) | |
Constructor which takes the point on the axis, front length, back length, heading, and width. | |
Box2d (const LineSegment2d &axis, const double width) | |
Constructor which takes the heading-axis and the width of the box | |
Box2d (const AABox2d &aabox) | |
Constructor which takes an AABox2d (axes-aligned box). | |
const Vec2d & | center () const |
Getter of the center of the box | |
double | center_x () const |
Getter of the x-coordinate of the center of the box | |
double | center_y () const |
Getter of the y-coordinate of the center of the box | |
double | length () const |
Getter of the length | |
double | width () const |
Getter of the width | |
double | half_length () const |
Getter of half the length | |
double | half_width () const |
Getter of half the width | |
double | heading () const |
Getter of the heading | |
double | cos_heading () const |
Getter of the cosine of the heading | |
double | sin_heading () const |
Getter of the sine of the heading | |
double | area () const |
Getter of the area of the box | |
double | diagonal () const |
Getter of the size of the diagonal of the box | |
void | GetAllCorners (std::vector< Vec2d > *const corners) const |
Getter of the corners of the box | |
const std::vector< Vec2d > & | GetAllCorners () const |
Getter of the corners of the box | |
bool | IsPointIn (const Vec2d &point) const |
Tests points for membership in the box | |
bool | IsPointOnBoundary (const Vec2d &point) const |
Tests points for membership in the boundary of the box | |
double | DistanceTo (const Vec2d &point) const |
Determines the distance between the box and a given point | |
double | DistanceTo (const LineSegment2d &line_segment) const |
Determines the distance between the box and a given line segment | |
double | DistanceTo (const Box2d &box) const |
Determines the distance between two boxes | |
bool | HasOverlap (const LineSegment2d &line_segment) const |
Determines whether this box overlaps a given line segment | |
bool | HasOverlap (const Box2d &box) const |
Determines whether these two boxes overlap | |
AABox2d | GetAABox () const |
Gets the smallest axes-aligned box containing the current one | |
void | RotateFromCenter (const double rotate_angle) |
Rotate from center. | |
void | Shift (const Vec2d &shift_vec) |
Shifts this box by a given vector | |
void | LongitudinalExtend (const double extension_length) |
Extend the box longitudinally | |
void | LateralExtend (const double extension_length) |
std::string | DebugString () const |
Gets a human-readable description of the box | |
void | InitCorners () |
double | max_x () const |
double | min_x () const |
double | max_y () const |
double | min_y () const |
静态 Public 成员函数 | |
static Box2d | CreateAABox (const Vec2d &one_corner, const Vec2d &opposite_corner) |
Creates an axes-aligned Box2d from two opposite corners | |
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 Vec2d & | point, |
double | heading, | ||
double | front_length, | ||
double | back_length, | ||
double | width | ||
) |
Constructor which takes the point on the axis, front length, back length, heading, and width.
center | The center of the rectangular bounding box. |
heading | The angle between the x-axis and the heading-axis, measured counter-clockwise. |
front_length | The length from the start point to the given point. |
back_length | The length from the end point to the given point. |
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 |
Constructor which takes an AABox2d (axes-aligned box).
aabox | The input AABox2d. |
|
inline |
|
inline |
|
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 |
|
static |
Creates an axes-aligned Box2d from two opposite corners
one_corner | One of the corners |
opposite_corner | The opposite corner to the first one |
std::string apollo::common::math::Box2d::DebugString | ( | ) | const |
Gets a human-readable description of the box
|
inline |
double apollo::common::math::Box2d::DistanceTo | ( | const Box2d & | box | ) | const |
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 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 |
AABox2d apollo::common::math::Box2d::GetAABox | ( | ) | const |
Gets the smallest axes-aligned box containing the current one
const std::vector< Vec2d > & apollo::common::math::Box2d::GetAllCorners | ( | ) | const |
void apollo::common::math::Box2d::GetAllCorners | ( | std::vector< Vec2d > *const | corners | ) | const |
|
inline |
|
inline |
bool apollo::common::math::Box2d::HasOverlap | ( | const Box2d & | box | ) | const |
Determines whether these two boxes overlap
line_segment | The other box |
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 |
|
inline |
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 |
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 |
|
inline |