-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question about direction vector in support functions #15
Comments
The direction vector should not be normalized in GJK. The algorithm does not care about the magnitude of direction-vector, it only uses the 'direction' of the direction-vector during geometric iteration. The direction of that direction-vector is used to find another support point along that direction, therefore you don't need to normalize it, and you don't care about the magnitude of that vector. Imagine an infinite ray-arrow 'pointing' in some direction. You don't care of its length (if it is normalized or not) at all. As Casey said in the GJK video ( http://mollyrocket.com/849 ), there's no divides in this algorithm, just pure cross and dot products ('easy' arithmetic with multiplication and addition). The direction-vector is never expected to be a unit vector or to be normalized apriori - it does not have to be normalized at all. I also recommend reading the following article on GJK: http://www.dyn4j.org/2010/04/gjk-gilbert-johnson-keerthi/ . I believe that everything regarding the magnitude and normalization of direction-vector behaves in the same way in EPA, MPR and other geometry-traversing algorithms – you just ignore the magnitude and don't normalize the direction-vector and don't expect that vector to be normalized. |
Thanks for the info. |
The magnitude of direction-vector can really be ignored algorithmically, I suppose this is true for libccd implementation. This is the actual testcase implementation of support function for various shapes: That __ccdSupport function you mentioned calls two of the shape-specific support functions (one for each of two shapes in a colliding pair), which can actually be implemented ignoring the magnitude of direction-vector. After all there's only 4 calls to ccdVec3Normalize() in mpr.c. I would test that by commenting those 4 lines ) I think there's no cases when the magnitude of direction-vector really matters in libccd support functions (except for precision issues with 'touching' contacts). You can write your own support functions for any shape without using the magnitude of direction-vector if you want. Sorry didn't have time to play with code, that's just my 2 cents. |
Hi Piotr, can I close this issue? |
Daniel, To sum up:
If the above statements are correct feel free to close the issue :) |
Hi,
This is a question rather than an issue.
I am trying to improve the performance of libccd support functions in ODE a bit by removing the unneeded transformations between world space and local space. While making these changes I noticed that in some cases the direction vector passed to support functions was normalized in ODE and in some cases it was not. I believe there is no need to normalize it as long as MPR is used at least it seems to be already normalized in portalDir(). Would you please confirm? Is it also the case for GJK? Should it be always expected to be a unit vector.
The full PR along with some discussions is available here - https://bitbucket.org/odedevs/ode/pull-requests/7/optimize-libccd-support-functions/diff#comment-13296486
Thanks,
Piotr
The text was updated successfully, but these errors were encountered: