# Calculate an approximate distance between two rigid bodies or OOB

Is there any easy way to get an approximate distance between two OOB?

I searched around and people talk about GJK algorithm, however I don't see it returning the distance between two convex objects even they are not colliding.

I don't need to be exact but just sphere checking is not acceptable in my case. Any ideas?

• Excuse my poor knowledge. I wonder what OOB and GJK stand for. Also I wonder what the distance is, the length of the smallest connection or the distance between the centers of the bodies. – Trilarion Sep 5 '14 at 9:11
• @Trilarion: I assume OOB = Object Oriented (Bounding) Box as opposed to AABB (Axis Aligned Bounding Box). GJK = Gilbert–Johnson–Keerthi distance algorithm – Philip Allgaier Sep 5 '14 at 11:24
• @NachoChip: This might give you some ideas: gamedev.net/topic/… – Philip Allgaier Sep 5 '14 at 11:25

## 1 Answer

I take that you meant OBB. (Oriented bounding box)

For an approximate distance calculate it as an AABB.

For an exact distance you can use the Separation Axis Theorem or the Minkowski Difference.

The Minkowski Difference will give you the distance between them (the penetration vector if they are colliding). With SAT you get the distance in each dimension and you have to calculate the vector yourself.