Axis-Aligned Bounding Box (AABB) representation for efficient collision detection.
An AABB is a rectangular cuboid whose faces are aligned with the coordinate axes. It is defined by a center point and half-extents (size) along each axis.
Key features of this implementation:
AABBs are primarily used for:
This implementation inherits from the Shape base class, allowing it to be used polymorphically with other geometric primitives in the library.
#include <aabb.hpp>
Public Member Functions | |
| constexpr | AABB () |
| Creates AABB at origin with zero size. | |
| constexpr | AABB (const Vector3D ¢er, const Fxp &size) |
| Creates AABB from center and size. | |
| constexpr | AABB (const Vector3D ¢er, const Vector3D &halfSize) |
| Creates AABB from center and half-extents. | |
| bool | Contains (const Vector3D &point) const override |
| Check if a point is inside the AABB. | |
| bool | ContainsAABB (const AABB &other) const |
| Check if another AABB is inside this AABB. | |
| bool | ContainsPoint (const Vector3D &point) const |
| Check if a point is inside the AABB. | |
| constexpr AABB | Expand (const Fxp &margin) const |
| Expand the AABB by a margin. | |
| constexpr Vector3D | GetClosestPoint (const Vector3D &point) const |
| Gets closest point on AABB to target point. | |
| constexpr Vector3D | GetMax () const |
| Gets maximum corner point. | |
| constexpr Vector3D | GetMin () const |
| Gets minimum corner point. | |
| Vector3D | GetPosition () const |
| Get the position of the AABB. | |
| constexpr Vector3D | GetSize () const |
| Gets box half-size. | |
| constexpr Fxp | GetSurfaceArea () const |
| Calculate the surface area of the AABB. | |
| std::array< Vector3D, 8 > | GetVertices () const |
| Get all 8 vertices of the AABB. | |
| constexpr Fxp | GetVolume () const |
| Calculate the volume of the AABB. | |
| AABB | Intersection (const AABB &other) const |
| Calculate the intersection of two AABBs. | |
| bool | Intersects (const Plane &plane) const override |
| Check if the AABB intersects with a plane. | |
| bool | IntersectsAABB (const AABB &other) const |
| Check if this AABB intersects with another AABB. | |
| AABB | Merge (const AABB &other) const |
| Merge this AABB with another AABB to create a new AABB that encompasses both. | |
| constexpr AABB | Scale (const Fxp &scale) const |
| Scale the AABB by a factor. | |
| constexpr void | SetPosition (const Vector3D &pos) |
| Sets shape center position. | |
Static Public Member Functions | |
| static constexpr AABB | FromMinMax (const Vector3D &minPoint, const Vector3D &maxPoint) |
| Creates AABB from min/max points. | |
Protected Attributes | |
| Vector3D | position |