Apollo
6.0
Open source self driving car software
|
Implements a class of (undirected) axes-aligned bounding boxes in 2-D. This class is referential-agnostic. More...
#include <aabox2d.h>
Public Member Functions | |
AABox2d ()=default | |
Default constructor. Creates an axes-aligned box with zero length and width at the origin. More... | |
AABox2d (const Vec2d ¢er, const double length, const double width) | |
Parameterized constructor. Creates an axes-aligned box with given center, length, and width. More... | |
AABox2d (const Vec2d &one_corner, const Vec2d &opposite_corner) | |
Parameterized constructor. Creates an axes-aligned box from two opposite corners. More... | |
AABox2d (const std::vector< Vec2d > &points) | |
Parameterized constructor. Creates an axes-aligned box containing all points in a given vector. More... | |
const Vec2d & | center () const |
Getter of center_. More... | |
double | center_x () const |
Getter of x-component of center_. More... | |
double | center_y () const |
Getter of y-component of center_. More... | |
double | length () const |
Getter of length_. More... | |
double | width () const |
Getter of width_. More... | |
double | half_length () const |
Getter of half_length_. More... | |
double | half_width () const |
Getter of half_width_. More... | |
double | area () const |
Getter of length_*width_. More... | |
double | min_x () const |
Returns the minimum x-coordinate of the box. More... | |
double | max_x () const |
Returns the maximum x-coordinate of the box. More... | |
double | min_y () const |
Returns the minimum y-coordinate of the box. More... | |
double | max_y () const |
Returns the maximum y-coordinate of the box. More... | |
void | GetAllCorners (std::vector< Vec2d > *const corners) const |
Gets all corners in counter clockwise order. More... | |
bool | IsPointIn (const Vec2d &point) const |
Determines whether a given point is in the box. More... | |
bool | IsPointOnBoundary (const Vec2d &point) const |
Determines whether a given point is on the boundary of the box. More... | |
double | DistanceTo (const Vec2d &point) const |
Determines the distance between a point and the box. More... | |
double | DistanceTo (const AABox2d &box) const |
Determines the distance between two boxes. More... | |
bool | HasOverlap (const AABox2d &box) const |
Determines whether two boxes overlap. More... | |
void | Shift (const Vec2d &shift_vec) |
Shift the center of AABox by the input vector. More... | |
void | MergeFrom (const AABox2d &other_box) |
Changes box to include another given box, as well as the current one. More... | |
void | MergeFrom (const Vec2d &other_point) |
Changes box to include a given point, as well as the current box. More... | |
std::string | DebugString () const |
Gets a human-readable debug string. More... | |
Implements a class of (undirected) axes-aligned bounding boxes in 2-D. This class is referential-agnostic.
|
default |
Default constructor. Creates an axes-aligned box with zero length and width at the origin.
apollo::common::math::AABox2d::AABox2d | ( | const Vec2d & | center, |
const double | length, | ||
const double | width | ||
) |
Parameterized constructor. Creates an axes-aligned box with given center, length, and width.
center | The center of the box |
length | The size of the box along the x-axis |
width | The size of the box along the y-axis |
Parameterized constructor. Creates an axes-aligned box from two opposite corners.
one_corner | One corner of the box |
opposite_corner | The opposite corner to the first one |
|
explicit |
Parameterized constructor. Creates an axes-aligned box containing all points in a given vector.
points | Vector of points to be included inside the box. |
|
inline |
Getter of length_*width_.
|
inline |
Getter of center_.
|
inline |
Getter of x-component of center_.
|
inline |
Getter of y-component of center_.
std::string apollo::common::math::AABox2d::DebugString | ( | ) | const |
Gets a human-readable debug string.
double apollo::common::math::AABox2d::DistanceTo | ( | const Vec2d & | point | ) | const |
Determines the distance between a point and the box.
point | The point whose distance to the box we wish to determine. |
double apollo::common::math::AABox2d::DistanceTo | ( | const AABox2d & | box | ) | const |
Determines the distance between two boxes.
box | Another box. |
void apollo::common::math::AABox2d::GetAllCorners | ( | std::vector< Vec2d > *const | corners | ) | const |
Gets all corners in counter clockwise order.
corners | Output where the corners are written |
|
inline |
Getter of half_length_.
|
inline |
Getter of half_width_.
bool apollo::common::math::AABox2d::HasOverlap | ( | const AABox2d & | box | ) | const |
Determines whether two boxes overlap.
box | Another box |
bool apollo::common::math::AABox2d::IsPointIn | ( | const Vec2d & | point | ) | const |
Determines whether a given point is in the box.
point | The point we wish to test for containment in the box |
bool apollo::common::math::AABox2d::IsPointOnBoundary | ( | const Vec2d & | point | ) | const |
Determines whether a given point is on the boundary of the box.
point | The point we wish to test for boundary membership |
|
inline |
Getter of length_.
|
inline |
Returns the maximum x-coordinate of the box.
|
inline |
Returns the maximum y-coordinate of the box.
void apollo::common::math::AABox2d::MergeFrom | ( | const AABox2d & | other_box | ) |
Changes box to include another given box, as well as the current one.
other_box | Another box |
void apollo::common::math::AABox2d::MergeFrom | ( | const Vec2d & | other_point | ) |
Changes box to include a given point, as well as the current box.
other_point | Another point |
|
inline |
Returns the minimum x-coordinate of the box.
|
inline |
Returns the minimum y-coordinate of the box.
void apollo::common::math::AABox2d::Shift | ( | const Vec2d & | shift_vec | ) |
Shift the center of AABox by the input vector.
shift_vec | The vector by which we wish to shift the box |
|
inline |
Getter of width_.