Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is AABB - Collision detection?

Hi I'm making a voxel game in Java and while researching all the different things I'd need to learn, I noticed that a lot of games use AABB for collision detection. And then I remembered seeing AABB in Minecraft also. But when I google what AABB is, it only comes up with other peoples code, or some organization out the history book. Stackoverflow, what is AABB?

like image 511
SemperAmbroscus Avatar asked Mar 19 '14 16:03

SemperAmbroscus


People also ask

What is an AABB in coding?

AABB stands for "Axis-Aligned Bounding Box." It is a fairly computationally- and memory-efficient way of representing a volume, typically used to see if two objects might be touching. Since it is axis-aligned, it does not necessarily "fit" your real 3D object very well.

How do I resolve an AABB collision?

Collision resolution means resolving the collision. Broadly, there are two approaches to this: prevention or pre-collision resolution (stop just at the onset of collision when the two AABBs touch), and post-collision resolution (once two AABBs overlap, move them backward in time until they no longer overlap).

What is AABB in Python?

AABB are a simple 3D rectangle with no orientation. It is up to the user to provide translation. An AABB is represented by an array of 2 x 3D vectors. The first vector represents the minimum extent.

What is meant by collision detection?

Collision detection is the computational problem of detecting the intersection of two or more objects.


1 Answers

AABB stands for "Axis-Aligned Bounding Box."

It is a fairly computationally- and memory-efficient way of representing a volume, typically used to see if two objects might be touching.

Since it is axis-aligned, it does not necessarily "fit" your real 3D object very well. AABB checks are often used as a coarse first-approximation to see if objects might be colliding. Then, if the AABB check passes, more detailed checks are made.

Example:

Imagine your world is 2D, and you draw it on a sheet of graph paper. You have some objects in the world (a ball, a tree, whatever). To make an AABB for one of the objects, you draw a rectangle around the object, making your lines parallel to the grid lines on the paper.

If you have the AABB for two objects, you can do some pretty simple math to see if those AABBs overlap. If they don't overlap, those two objects couldn't possibly be touching, so it's an easy early-out for your collision algorithm.

This generalizes to 3D (and more-Ds) fairly easily.

You might want to check out gamedev.stackexchange.com, too.

like image 200
jwd Avatar answered Oct 15 '22 13:10

jwd