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?

  • \$\begingroup\$ 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. \$\endgroup\$ – Trilarion Sep 5 '14 at 9:11
  • 1
    \$\begingroup\$ @Trilarion: I assume OOB = Object Oriented (Bounding) Box as opposed to AABB (Axis Aligned Bounding Box). GJK = Gilbert–Johnson–Keerthi distance algorithm \$\endgroup\$ – Philip Allgaier Sep 5 '14 at 11:24
  • \$\begingroup\$ @NachoChip: This might give you some ideas: gamedev.net/topic/… \$\endgroup\$ – Philip Allgaier Sep 5 '14 at 11:25

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.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.