Interactive 3D visualization tool for Axis-Aligned Bounding Box (AABB) construction and collision detection
Loading 3D Visualizer...
Position
Rotation
Scale
Position
Size
Collision Status
Not Colliding
// AABB 计算
function computeAABB(vertices, transform) {
const min = { x: Infinity, y: Infinity, z: Infinity };
const max = { x: -Infinity, y: -Infinity, z: -Infinity };
for (const vertex of vertices) {
const transformed = applyTransform(vertex, transform);
min.x = Math.min(min.x, transformed.x);
min.y = Math.min(min.y, transformed.y);
min.z = Math.min(min.z, transformed.z);
max.x = Math.max(max.x, transformed.x);
max.y = Math.max(max.y, transformed.y);
max.z = Math.max(max.z, transformed.z);
}
return { min, max };
}
// AABB 碰撞检测
function testAABBCollision(aabb1, aabb2) {
return (
aabb1.min.x <= aabb2.max.x && aabb1.max.x >= aabb2.min.x &&
aabb1.min.y <= aabb2.max.y && aabb1.max.y >= aabb2.min.y &&
aabb1.min.z <= aabb2.max.z && aabb1.max.z >= aabb2.min.z
);
}Axis-Aligned Bounding Box (AABB) is a fundamental concept in 3D graphics and game development. It's the simplest form of bounding volume, defined by minimum and maximum points along each axis, making collision detection extremely fast.
This interactive tool helps you understand how AABBs are constructed from 3D geometry and how they respond to transformations. You can experiment with different shapes, adjust their position/rotation/scale, and see the AABB update in real-time.
The collision test area demonstrates AABB-AABB intersection testing, a core technique used in game engines for broad-phase collision detection, spatial partitioning (octrees), and frustum culling.
Implement efficient collision detection systems using AABB as the first-pass broad-phase test
Use AABB trees for spatial partitioning and dynamic object management
Optimize rendering by testing if object AABBs are within the camera frustum
Accelerate ray-object intersection tests using AABB as preliminary check
To construct an AABB, iterate through all vertices of the geometry, apply the transformation matrix (position, rotation, scale), then compute the minimum and maximum points along each axis.
Two AABBs collide if they overlap on all three axes. For each axis, check if AABB1.min <= AABB2.max AND AABB1.max >= AABB2.min.
Construction: O(n) where n is the number of vertices. Collision test: O(1) constant time.