• Advertisement
Sign in to follow this  

GJK algorithm

This topic is 3446 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello I am trying to implement the GJK algorithm. I have got it working for when the objects are not intersecting, but I am having problems getting anything meaningful when the objects are intersecting. Is the GJK algorithm useful for determining anything about collision contact points when the objects are overlapping? I have googled around a bit and keep seeing something called the EPA algorithm, does anyone know of any papers or explanations of EPA? Thanks!

Share this post


Link to post
Share on other sites
Advertisement

Thanks for the link. The page is a bit confusing on what the algorithm is trying to accomplish. Is it just trying to find out if the shapes overlap? I.E. that the origin is in the minkowski difference? Can you determine the penetration depth from it easier than with GJK/EPA?

Thanks again :)

Share this post


Link to post
Share on other sites
yeah, it's trying to find if the origin is in the minkowski difference.

hmm actually, this algo still seems to require an EPA to find the collision info :/

I'm also confused by their explanation of the contact manifold.

Share this post


Link to post
Share on other sites
MPR can actually be used in 'replacement' of EPA if you'd like. I use a set of implementations that provide contact location, depth, normal, and also a conservative distance estimation in my engine to complement GJK. I use these with the persistent manifold concept commonly employed by GJK-based methods.

The best description of the algorithm I've found is the gem itself in GPG7, though you can also take a look at the source. I don't have time to do an overview right now, but the xenocollide forums have scattered tidbits about how it works.

Note that the usual implementation will give you a 'pretty good' approximation of the penetration vector, but for unusual shapes (large flat boxes and such) it will sometimes produce something less than perfect. Usually this doesn't matter in games, especially with continuous detection since things never get too deep into penetration.

It's also fast- fast enough to be used as the primary collision detection system alone, even. That and the ease of implementation of MPR are why I chose it over EPA.

Share this post


Link to post
Share on other sites
I gave up on GJK when trying to get EPA working, too much precision errors in the algorithm itself too.

Loop up Bullet, Erwin Coumans seems to have gotten it right in it.

Personally, I much prefer SAT.

Share this post


Link to post
Share on other sites
Yea I am having quite a few problems with it when the collision is very small. In particular I seem to get an infinite loop when the shapes collide at or close to a vertex. I will give SAT a try tomorrow.

Share this post


Link to post
Share on other sites
Quote:
Original post by PhysicsNoob
Yea I am having quite a few problems with it when the collision is very small. In particular I seem to get an infinite loop when the shapes collide at or close to a vertex. I will give SAT a try tomorrow.


Yes, that's what I would get, if the shapes were barely touching sometimes the computation would explode (floats would overflow, resulting in garbage values), my code was already to complex and had too many "special case" code paths I didn't want to maintain in the future to add even more, so I scraped it.

IMO, GJK is mathematically sound, and simple in that mathematical sense, but it is too hard to properly implement with limited floating point precision, there are too many gotchas, that said, Bullet does it [smile].

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement