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

Invalid convex_hull when points are repeated #109

Closed
asinghvi17 opened this issue May 8, 2024 · 9 comments · Fixed by #119
Closed

Invalid convex_hull when points are repeated #109

asinghvi17 opened this issue May 8, 2024 · 9 comments · Fixed by #119

Comments

@asinghvi17
Copy link
Contributor

Consider the following MWE:

using CairoMakie, DelaunayTriangulation
data = rand(Point2f, 10)
Makie.convert_arguments(::Makie.PointBased, ch::DelaunayTriangulation.ConvexHull) = (Makie.Point.(view(ch.points, ch.vertices)),) # just to make plotting easier

f, a1, p1 = lines(convex_hull(data); axis = (; title = "points")) # this is fine
a2, p2 = lines(f[1, 2], convex_hull(vcat(data, data)); axis = (; title = "vcat(points, points)")) # this is NOT fine

iTerm2 fNCt8V

@asinghvi17 asinghvi17 changed the title Potential issue with convex_hull when points are repeated Invalid convex_hull when points are repeated May 8, 2024
@asinghvi17
Copy link
Contributor Author

For context, I was looking at depending on DelaunayTriangulation.jl in GeometryOps for some triangulation tasks. All geographic polygons must have polygon[begin] == polygon[end], so this comes up quite often when taking the convex hull of a set of polygons.

@DanielVandH
Copy link
Member

Hm. I didn't really intend to support duplicate points anywhere - in fact, I thought this function also would throw a DuplicatePointsError like triangulate does. I'm open to supporting it though. Can you check if it works if you add

unique!(i -> get_point(points, i), insertion_order)

in convex_hull! after insertion_order = lexicographic_order(points)?

@asinghvi17
Copy link
Contributor Author

Yep, that works! I can perform that check locally, but it would make sense to place that here as well. It could also be controlled by a keyword argument if that's desired for performance.

@DanielVandH
Copy link
Member

Probably don't need to bother with a keyword, I don't think it'll slow things down too much. If you're able to, would you mind making a PR with that change in the convex_hull! function? A simple test that convex_hull(points) == convex_hull(vcat(points, points)) (or something like that, not sure if == works on ConvexHull or if I never implemented it yet) would probably suffice.

@asinghvi17
Copy link
Contributor Author

Will get a PR up by tomorrow!

@DanielVandH
Copy link
Member

Is this something you still need @asinghvi17?

@asinghvi17
Copy link
Contributor Author

Yes! Sorry, I lost track of this and forgot to push the PR.

@DanielVandH
Copy link
Member

No worries, there's no rush. I just happened to remember about it today so thought I'd check in. Thanks.

@DanielVandH
Copy link
Member

DanielVandH commented Jul 1, 2024

Should now be fixed once v1.0.4 is released

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

Successfully merging a pull request may close this issue.

2 participants