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

enhancement #30

Open lirun-sat opened 1 year ago

lirun-sat commented 1 year ago

this code just outputs the minimum distance between convex objects and does not provide the closest points (witness points) on objects.

How to add this feature to the current code?

lirun-sat commented 1 year ago

First of all, thanks a lot for this piece of software. I was looking quite a while to find something like this.

ywyw2015 commented 1 year ago

@MattiaMontanari At v3.0.1, the return value of lambdas seems garbage.How to add the lambdas to the current branch?

ywyw2015 commented 1 year ago

In #12 ,the mentioned simplex.p ,simplex.q and simplex.lambdas also removed in latest branch.

MattiaMontanari commented 1 year ago

@ywyw2015 yes, I removed lambdas. My first implementation returned witness points, but it updated the barycentric coordinates (lambdas) at each GJK iteration. They brought some overheads and made the code more complex. So I removed them and focused on the most basic distance query.

Given the demand, I do intend to add the computation of witness points, but I still need to found the time...

If you want to give it a go here's my idea: preserve performance by computing the witness points only after gjk has converged. I have not figured out the details, but if you use the separating vector (returned by the sub-algorithm) and the support function for each body (mind the sign!) you should have all you need. Firstly you need to find who many witness points there are on each body, then you need to compute the barycentric coordinates.

ywyw2015 commented 1 year ago

Thank you for your reply, I will go to learn more about it according to your suggestion