Skip to content
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

Convex hull algorithm fails in some cases #498

Open
sixFingers opened this issue Jun 9, 2016 · 1 comment
Open

Convex hull algorithm fails in some cases #498

sixFingers opened this issue Jun 9, 2016 · 1 comment

Comments

@sixFingers
Copy link

Hi, i noticed that, in rare cases, jarvis_march fails to produce a valid hull. Instead, it keeps looping around the supplied point list. I have a really hard time understanding the problem (shouldn't be co-planarity, since it works in other cases). Anyway, i applied a patch that works for me. Not sure a PR is worth it, here my addition (which is admittedly not really mathematic-ish):

local checked = 1

while(visited[q]) do
    checked = checked + 1
    q = points[q + 1] and q + 1 or 1

    if (checked == #points) then
        return hull
    end
end

.. which goes right at line 40, before the loop. This at least prevents the algo to loop over infinitely, while still supplying a valid hull (at least, it looks to me in a test case with ~ 200 procedurally generated point clouds). I'm bothering to write here because it looks @Yonaba's Lua implementation is the landing page for people with convex-hull needs :)

@sixFingers
Copy link
Author

Well, after more work, i discovered that the bug persists. If you're interested, this implementation worked for me. My - really rough - Lua port is here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant