MattiaMontanari / openGJK

Fast and reliable implementation of the Gilbert-Johnson-Keerthi (GJK) algorithm for C, C#, Go, Matlab and Python
https://www.mattiamontanari.com/opengjk/
GNU General Public License v3.0
135 stars 37 forks source link

Meaning of Minimal Distance for Collision #17

Closed scleronomic closed 3 years ago

scleronomic commented 3 years ago

What is the minimal distance indicates for the case of collision? I had a quick look at the code and believe the returned value is just a lower bound of the penetration depth but not the exact value. I guess for the exact value, you would need further iterations, for example, via EPA. If this is correct, it would be good if you could indicate it a bit more clearly.

Is it planned also to include EPA to get the correct value in the case of collisions?

MattiaMontanari commented 3 years ago

"What is the minimal distance indicates for the case of collision?" you should look at distance queries in the other way: What is the distance in case of collision? Clearly 0 and that's where distance algorithms, such as GJK, meet their goal. GJK does not give any information about penetration depth and if you dive deeper you'll see that GJK will return tiny number or zero in case of collision.

EPA can compute penetration vector - note that there this won't be "exact" as there is no such a thing in nature and many definitions exist.

In the first line of OpenGJK readme you can read that this lib can "compute the minimum distance between convex polytopes". If you made it that far, you can't ask to indicate more clearly that GJK does not do anything about penetration depth. I'm getting a lot of demand to implement EPA but I don't have concrete plans to implement it at the moment