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

How to judge if two bodies penetrate each other or not ? #43

Closed wangxi0706 closed 8 months ago

wangxi0706 commented 1 year ago

Thanks for the code! Neat and elegant.

Since the returned distance is always >=0, how can we judge if they penetrate? Using d > 1e-15 or other tolerances?

MattiaMontanari commented 9 months ago

@wangxi0706 That's right. 1e-15 is very small however. Set a larger number and compare it to what you get with 1e-15. Set this tolerance large enough, but not too large. 1e-8 may be enough. If you get similar results to 1e-15 then you'll be good to go.

Overall, It depends on the algorithm you use after GJK: Are you using EPA?

MattiaMontanari commented 8 months ago

@wangxi0706 feel free to reopen the issue if you have more questions