Apollo  6.0
Open source self driving car software
Public Member Functions | List of all members
apollo::common::math::AABox2d Class Reference

Implements a class of (undirected) axes-aligned bounding boxes in 2-D. This class is referential-agnostic. More...

#include <aabox2d.h>

Collaboration diagram for apollo::common::math::AABox2d:
Collaboration graph

Public Member Functions

 AABox2d ()=default
 Default constructor. Creates an axes-aligned box with zero length and width at the origin. More...
 
 AABox2d (const Vec2d &center, 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 Vec2dcenter () 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...
 

Detailed Description

Implements a class of (undirected) axes-aligned bounding boxes in 2-D. This class is referential-agnostic.

Constructor & Destructor Documentation

◆ AABox2d() [1/4]

apollo::common::math::AABox2d::AABox2d ( )
default

Default constructor. Creates an axes-aligned box with zero length and width at the origin.

◆ AABox2d() [2/4]

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.

Parameters
centerThe center of the box
lengthThe size of the box along the x-axis
widthThe size of the box along the y-axis

◆ AABox2d() [3/4]

apollo::common::math::AABox2d::AABox2d ( const Vec2d one_corner,
const Vec2d opposite_corner 
)

Parameterized constructor. Creates an axes-aligned box from two opposite corners.

Parameters
one_cornerOne corner of the box
opposite_cornerThe opposite corner to the first one

◆ AABox2d() [4/4]

apollo::common::math::AABox2d::AABox2d ( const std::vector< Vec2d > &  points)
explicit

Parameterized constructor. Creates an axes-aligned box containing all points in a given vector.

Parameters
pointsVector of points to be included inside the box.

Member Function Documentation

◆ area()

double apollo::common::math::AABox2d::area ( ) const
inline

Getter of length_*width_.

Returns
The area of the box

◆ center()

const Vec2d& apollo::common::math::AABox2d::center ( ) const
inline

Getter of center_.

Returns
Center of the box

◆ center_x()

double apollo::common::math::AABox2d::center_x ( ) const
inline

Getter of x-component of center_.

Returns
x-component of the center of the box

◆ center_y()

double apollo::common::math::AABox2d::center_y ( ) const
inline

Getter of y-component of center_.

Returns
y-component of the center of the box

◆ DebugString()

std::string apollo::common::math::AABox2d::DebugString ( ) const

Gets a human-readable debug string.

Returns
A string

◆ DistanceTo() [1/2]

double apollo::common::math::AABox2d::DistanceTo ( const Vec2d point) const

Determines the distance between a point and the box.

Parameters
pointThe point whose distance to the box we wish to determine.

◆ DistanceTo() [2/2]

double apollo::common::math::AABox2d::DistanceTo ( const AABox2d box) const

Determines the distance between two boxes.

Parameters
boxAnother box.

◆ GetAllCorners()

void apollo::common::math::AABox2d::GetAllCorners ( std::vector< Vec2d > *const  corners) const

Gets all corners in counter clockwise order.

Parameters
cornersOutput where the corners are written

◆ half_length()

double apollo::common::math::AABox2d::half_length ( ) const
inline

Getter of half_length_.

Returns
Half of the length of the box

◆ half_width()

double apollo::common::math::AABox2d::half_width ( ) const
inline

Getter of half_width_.

Returns
Half of the width of the box

◆ HasOverlap()

bool apollo::common::math::AABox2d::HasOverlap ( const AABox2d box) const

Determines whether two boxes overlap.

Parameters
boxAnother box

◆ IsPointIn()

bool apollo::common::math::AABox2d::IsPointIn ( const Vec2d point) const

Determines whether a given point is in the box.

Parameters
pointThe point we wish to test for containment in the box

◆ IsPointOnBoundary()

bool apollo::common::math::AABox2d::IsPointOnBoundary ( const Vec2d point) const

Determines whether a given point is on the boundary of the box.

Parameters
pointThe point we wish to test for boundary membership

◆ length()

double apollo::common::math::AABox2d::length ( ) const
inline

Getter of length_.

Returns
The length of the box

◆ max_x()

double apollo::common::math::AABox2d::max_x ( ) const
inline

Returns the maximum x-coordinate of the box.

Returns
x-coordinate

◆ max_y()

double apollo::common::math::AABox2d::max_y ( ) const
inline

Returns the maximum y-coordinate of the box.

Returns
y-coordinate

◆ MergeFrom() [1/2]

void apollo::common::math::AABox2d::MergeFrom ( const AABox2d other_box)

Changes box to include another given box, as well as the current one.

Parameters
other_boxAnother box

◆ MergeFrom() [2/2]

void apollo::common::math::AABox2d::MergeFrom ( const Vec2d other_point)

Changes box to include a given point, as well as the current box.

Parameters
other_pointAnother point

◆ min_x()

double apollo::common::math::AABox2d::min_x ( ) const
inline

Returns the minimum x-coordinate of the box.

Returns
x-coordinate

◆ min_y()

double apollo::common::math::AABox2d::min_y ( ) const
inline

Returns the minimum y-coordinate of the box.

Returns
y-coordinate

◆ Shift()

void apollo::common::math::AABox2d::Shift ( const Vec2d shift_vec)

Shift the center of AABox by the input vector.

Parameters
shift_vecThe vector by which we wish to shift the box

◆ width()

double apollo::common::math::AABox2d::width ( ) const
inline

Getter of width_.

Returns
The width of the box

The documentation for this class was generated from the following file: