ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
BoundingBox2D.h
Go to the documentation of this file.
1/**
2 * @file BoundingBox2D.h
3 * @brief Defines the BoundingBox2D class for managing 2D bounding boxes.
4 *
5 * The BoundingBox2D class provides functionality to represent, update, and query
6 * axis-aligned 2D bounding boxes for collision detection and spatial representation.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../../Utils/Math/Vector2D.h"
16
17/**
18 * @class BoundingBox2D
19 * @brief Represents a 2D axis-aligned bounding box.
20 */
22private:
23 Vector2D min; ///< Minimum corner of the bounding box.
24 Vector2D max; ///< Maximum corner of the bounding box.
25 Vector2D mid; ///< Center point of the bounding box.
26
27public:
28 /**
29 * @brief Default constructor initializing the bounding box to zero dimensions.
30 */
32
33 /**
34 * @brief Constructs a BoundingBox2D with specified minimum and maximum corners.
35 * @param min Minimum corner of the bounding box.
36 * @param max Maximum corner of the bounding box.
37 */
38 BoundingBox2D(const Vector2D& min, const Vector2D& max);
39
40 /**
41 * @brief Updates the bounds of the bounding box to include the specified point.
42 * @param current The point to include in the bounding box.
43 */
44 void UpdateBounds(const Vector2D& current);
45
46 /**
47 * @brief Gets the minimum corner of the bounding box.
48 * @return Minimum corner as a Vector2D.
49 */
51
52 /**
53 * @brief Gets the maximum corner of the bounding box.
54 * @return Maximum corner as a Vector2D.
55 */
57
58 /**
59 * @brief Gets the center point of the bounding box.
60 * @return Center point as a Vector2D.
61 */
63
64 /**
65 * @brief Checks if this bounding box overlaps with another BoundingBox2D.
66 * @param bb Pointer to the other BoundingBox2D.
67 * @return True if the bounding boxes overlap, false otherwise.
68 */
69 bool Overlaps(BoundingBox2D* bb);
70
71 /**
72 * @brief Checks if this bounding box overlaps with another box defined by min and max corners.
73 * @param minI Minimum corner of the other box.
74 * @param maxI Maximum corner of the other box.
75 * @return True if the boxes overlap, false otherwise.
76 */
77 bool Overlaps(const Vector2D& minI, const Vector2D& maxI);
78
79 /**
80 * @brief Checks if this bounding box contains a specified point.
81 * @param v The point to check.
82 * @return True if the point is within the bounding box, false otherwise.
83 */
84 bool Contains(const Vector2D& v);
85};
Represents a 2D axis-aligned 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.
BoundingBox2D()
Default constructor initializing the bounding box to zero dimensions.
Vector2D min
Minimum corner of the bounding box.
Vector2D GetMinimum()
Gets the minimum corner of the bounding box.
Vector2D GetMaximum()
Gets the maximum corner of the bounding box.
bool Contains(const Vector2D &v)
Checks if this bounding box contains a specified point.
Vector2D max
Maximum corner of the bounding box.
Vector2D mid
Center point of the bounding box.
void UpdateBounds(const Vector2D &current)
Updates the bounds of the bounding box to include the specified point.
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27