ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundingBox2D Class Reference

Represents a 2D axis-aligned bounding box. More...

#include <BoundingBox2D.h>

Collaboration diagram for BoundingBox2D:

Public Member Functions

 BoundingBox2D ()
 Default constructor initializing the bounding box to zero dimensions.
 
 BoundingBox2D (const Vector2D &min, const Vector2D &max)
 Constructs a BoundingBox2D with specified minimum and maximum corners.
 
void UpdateBounds (const Vector2D &current)
 Updates the bounds of the bounding box to include the specified point.
 
Vector2D GetMinimum ()
 Gets the minimum corner of the bounding box.
 
Vector2D GetMaximum ()
 Gets the maximum corner of the bounding box.
 
Vector2D GetCenter ()
 Gets the center point of the bounding box.
 
bool Overlaps (BoundingBox2D *bb)
 Checks if this bounding box overlaps with another BoundingBox2D.
 
bool Overlaps (const Vector2D &minI, const Vector2D &maxI)
 Checks if this bounding box overlaps with another box defined by min and max corners.
 
bool Contains (const Vector2D &v)
 Checks if this bounding box contains a specified point.
 

Private Attributes

Vector2D min
 Minimum corner of the bounding box.
 
Vector2D max
 Maximum corner of the bounding box.
 
Vector2D mid
 Center point of the bounding box.
 

Detailed Description

Represents a 2D axis-aligned bounding box.

Definition at line 21 of file BoundingBox2D.h.

Constructor & Destructor Documentation

◆ BoundingBox2D() [1/2]

Default constructor initializing the bounding box to zero dimensions.

Definition at line 3 of file BoundingBox2D.cpp.

References max, mid, and min.

◆ BoundingBox2D() [2/2]

BoundingBox2D ( const Vector2D min,
const Vector2D max 
)

Constructs a BoundingBox2D with specified minimum and maximum corners.

Parameters
minMinimum corner of the bounding box.
maxMaximum corner of the bounding box.

Definition at line 10 of file BoundingBox2D.cpp.

References max, mid, min, Vector2D::X, and Vector2D::Y.

Member Function Documentation

◆ Contains()

bool Contains ( const Vector2D v)

Checks if this bounding box contains a specified point.

Parameters
vThe point to check.
Returns
True if the point is within the bounding box, false otherwise.

Definition at line 52 of file BoundingBox2D.cpp.

References max, min, Vector2D::X, and Vector2D::Y.

Referenced by QuadTree::Intersect().

◆ GetCenter()

Vector2D GetCenter ( )

Gets the center point of the bounding box.

Returns
Center point as a Vector2D.

Definition at line 34 of file BoundingBox2D.cpp.

References mid.

Referenced by Node::CreateChildNodes().

◆ GetMaximum()

Vector2D GetMaximum ( )

Gets the maximum corner of the bounding box.

Returns
Maximum corner as a Vector2D.

Definition at line 30 of file BoundingBox2D.cpp.

References max.

Referenced by Node::CreateChildNodes(), Triangle2D::DidIntersectSAT(), and Overlaps().

◆ GetMinimum()

Vector2D GetMinimum ( )

Gets the minimum corner of the bounding box.

Returns
Minimum corner as a Vector2D.

Definition at line 26 of file BoundingBox2D.cpp.

References min.

Referenced by Node::CreateChildNodes(), Triangle2D::DidIntersectSAT(), and Overlaps().

◆ Overlaps() [1/2]

bool Overlaps ( BoundingBox2D bb)

Checks if this bounding box overlaps with another BoundingBox2D.

Parameters
bbPointer to the other BoundingBox2D.
Returns
True if the bounding boxes overlap, false otherwise.

Definition at line 38 of file BoundingBox2D.cpp.

References GetMaximum(), GetMinimum(), max, min, Vector2D::X, and Vector2D::Y.

Referenced by Triangle2D::DidIntersect().

◆ Overlaps() [2/2]

bool Overlaps ( const Vector2D minI,
const Vector2D maxI 
)

Checks if this bounding box overlaps with another box defined by min and max corners.

Parameters
minIMinimum corner of the other box.
maxIMaximum corner of the other box.
Returns
True if the boxes overlap, false otherwise.

Definition at line 45 of file BoundingBox2D.cpp.

References max, min, Vector2D::X, and Vector2D::Y.

◆ UpdateBounds()

void UpdateBounds ( const Vector2D current)

Updates the bounds of the bounding box to include the specified point.

Parameters
currentThe point to include in the bounding box.

Definition at line 18 of file BoundingBox2D.cpp.

References max, Vector2D::Maximum(), mid, min, Vector2D::Minimum(), Vector2D::X, and Vector2D::Y.

Member Data Documentation

◆ max

Vector2D max
private

Maximum corner of the bounding box.

Definition at line 24 of file BoundingBox2D.h.

Referenced by BoundingBox2D(), BoundingBox2D(), Contains(), GetMaximum(), Overlaps(), Overlaps(), and UpdateBounds().

◆ mid

Vector2D mid
private

Center point of the bounding box.

Definition at line 25 of file BoundingBox2D.h.

Referenced by BoundingBox2D(), BoundingBox2D(), GetCenter(), and UpdateBounds().

◆ min

Vector2D min
private

Minimum corner of the bounding box.

Definition at line 23 of file BoundingBox2D.h.

Referenced by BoundingBox2D(), BoundingBox2D(), Contains(), GetMinimum(), Overlaps(), Overlaps(), and UpdateBounds().


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