A 2D axis-aligned bounding box.
More...
#include "donner/base/Box.h"
|
|
| Box () |
| | Default constructor: Creates an empty box centered on (0, 0).
|
| | Box (const Vector2< T > &topLeft, const Vector2< T > &bottomRight) |
| | Construct a new box with the given top-left and bottom-right corners.
|
|
| ~Box ()=default |
| | Destructor.
|
| | Box (const Box< T > &other)=default |
| | Copy constructor.
|
| Box< T > & | operator= (const Box< T > &other)=default |
| | Copy assignment operator.
|
| | Box (Box< T > &&other) noexcept=default |
| | Move constructor.
|
| Box< T > & | operator= (Box< T > &&other) noexcept=default |
| | Move assignment operator.
|
| void | addPoint (const Vector2< T > &point) |
| | Expand to include the provided point.
|
| void | addBox (const Box< T > &box) |
| | Adds a bounding box inside this bounding box.
|
| Box | toOrigin () const |
| | Return a box with the same size but moved to the origin, i.e.
|
|
T | width () const |
| | Returns the box width.
|
|
T | height () const |
| | Returns the box height.
|
|
Vector2< T > | size () const |
| | Returns the box size.
|
|
bool | isEmpty () const |
| | Returns true if the box has zero width or height.
|
| bool | contains (const Vector2< T > &point) const |
| | Returns true if the box contains the given point.
|
| Box< T > | inflatedBy (T amount) const |
| | Inflates the box size by the given amount in all directions.
|
|
Box< T > | operator- (const Vector2< T > &vec) const |
| | Return the box moved by subtracting the given vector.
|
|
Box< T > & | operator-= (const Vector2< T > &vec) |
| | Move the box by subtracting the given vector.
|
|
Box< T > | operator+ (const Vector2< T > &vec) const |
| | Return the box moved by adding the given vector.
|
|
Box< T > & | operator+= (const Vector2< T > &vec) |
| | Move the box by adding the given vector.
|
|
bool | operator== (const Box< T > &other) const |
| | Equality operator.
|
|
bool | operator!= (const Box< T > &rhs) const |
| | Inequality operator.
|
|
| static Box< T > | FromXYWH (T x, T y, T width, T height) |
| | Creates a Box from x, y, width, and height.
|
| static Box< T > | CreateEmpty (const Vector2< T > &point) |
| | Create an empty box that is centered on the given point.
|
| static Box< T > | WithSize (const Vector2< T > &size) |
| | Create a box with the given size, with the top-left corner at the origin.
|
| static Box< T > | Union (const Box< T > &a, const Box< T > &b) |
| | Create a new box that is expanded to include both boxes.
|
|
|
Vector2< T > | topLeft |
| | The top-left corner of the box.
|
|
Vector2< T > | bottomRight |
| | The bottom-right corner of the box.
|
|
|
std::ostream & | operator<< (std::ostream &os, const Box< T > &box) |
| | Ostream output operator.
|
template<typename T>
struct donner::Box< T >
A 2D axis-aligned bounding box.
For example, to construct a box, add points to it, and query its size:
assert(box.size() ==
Vector2d(3.0, 2.0));
Vector2< double > Vector2d
Shorthand for Vector2<double>.
Definition Vector2.h:394
Box< double > Boxd
Shorthand for Box<double>.
Definition Box.h:211
- Template Parameters
-
| T | Element type, e.g. double, float, int, etc. |
◆ Box() [1/3]
Construct a new box with the given top-left and bottom-right corners.
- Parameters
-
| topLeft | Top-left corner. |
| bottomRight | Bottom-right corner. |
◆ Box() [2/3]
Copy constructor.
- Parameters
-
◆ Box() [3/3]
Move constructor.
- Parameters
-
◆ addBox()
Adds a bounding box inside this bounding box.
- Parameters
-
◆ addPoint()
Expand to include the provided point.
- Parameters
-
◆ contains()
Returns true if the box contains the given point.
- Parameters
-
◆ CreateEmpty()
Create an empty box that is centered on the given point.
- Parameters
-
◆ FromXYWH()
Creates a Box from x, y, width, and height.
- Parameters
-
| x | X coordinate of the top-left corner. |
| y | Y coordinate of the top-left corner. |
| width | Width of the box. |
| height | Height of the box. |
◆ inflatedBy()
Inflates the box size by the given amount in all directions.
- Parameters
-
| amount | Amount to inflate the box by. |
◆ operator=() [1/2]
Move assignment operator.
- Parameters
-
◆ operator=() [2/2]
Copy assignment operator.
- Parameters
-
◆ toOrigin()
Return a box with the same size but moved to the origin, i.e.
with the top-left corner at (0, 0).
◆ Union()
Create a new box that is expanded to include both boxes.
- Parameters
-
◆ WithSize()
Create a box with the given size, with the top-left corner at the origin.
- Parameters
-
The documentation for this struct was generated from the following file: