AABB (Axis-Aligned Bounding Box) is a geometry library used to represent a rectangle that is aligned with the X, Y, and Z axes. It is commonly used in collision detection algorithms, physics simulations, and 3D graphics.

**Example 1:** Checking if two AABBs intersect

**Example 2:** Getting the center of an AABB

bool intersect(const AABB& a, const AABB& b) { return (a.min.x <= b.max.x && a.max.x >= b.min.x) && (a.min.y <= b.max.y && a.max.y >= b.min.y) && (a.min.z <= b.max.z && a.max.z >= b.min.z); } AABB a({0, 0, 0}, {10, 10, 10}); AABB b({5, 5, 5}, {15, 15, 15}); if (intersect(a, b)) { std::cout << "AABBs intersect!" << std::endl; }

Vec3 center(const AABB& a) { return (a.min + a.max) * 0.5f; } AABB a({0, 0, 0}, {10, 10, 10}); Vec3 center = center(a); std::cout << "Center: " << center.x << ", " << center.y << ", " << center.z << std::endl;These examples do not specify an external package library, as AABB is a common data structure that can be implemented in any C++ program. However, there are various 3D graphics libraries and physics engines that include AABBs in their implementations, such as OpenGL, DirectX, and the Box2D physics engine.

Frequently Used Methods

Frequently Used Methods

Frequently Used Methods

Related in langs

Frequently Used Methods

Related