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

[BUG]: clipping when getting polygon from Voronoi tessellation hangs for certain configurations #206

Closed
rubenseyer opened this issue Oct 18, 2024 · 4 comments

Comments

@rubenseyer
Copy link

Describe the bug

I want to perform a Voronoi tessellation of a periodic window, but I'm solving this by making mirror copies of points where necessary and then clipping my polygons to the original bounding box. Thus, in an edge case, the resulting set of points can lie on a triangle (up to floating point precision). Some of these configurations seem to hang for me when attempting to get the clipped polygons.

Reproducer

using DelaunayTriangulation
using Random: seed!

seed!(123) # randomness is not relevant here, but just to be sure
pts = [(0.1,0.2), (1.1,0.2), (0.1,1.2)]
D = triangulate(pts)
V = voronoi(D)
bbox = (0., 1., 0., 1.)
get_polygon_coordinates(V, 3, bbox)  # hangs

I expect to obtain the clipped polygons rather than the code hanging.

Environment information

Julia Version 1.10.2
Commit bd47eca2c8a (2024-03-01 10:14 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: Linux (x86_64-linux-gnu)
  CPU: 12 × 12th Gen Intel(R) Core(TM) i5-1245U
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-15.0.7 (ORCJIT, alderlake)
Threads: 1 default, 0 interactive, 1 GC (on 12 virtual cores)
Environment:
  JULIA_EDITOR = code
  JULIA_NUM_THREADS = 
Status `~/xyz/Project.toml`
  [927a84f5] DelaunayTriangulation v1.6.0
@DanielVandH
Copy link
Member

DanielVandH commented Oct 18, 2024 via email

@DanielVandH
Copy link
Member

DanielVandH commented Oct 18, 2024

Can you try #207 and see if it fixes your use case? Your MWE works now

   Random.seed!(123)
    pts = [(0.1, 0.2), (1.1, 0.2), (0.1, 1.7)]
    tri = triangulate(pts)
    vorn = voronoi(tri, clip=true, clip_polygon=(
        [(0.0, 0.0), (1.0, 0.0), (1.0, 1.0), (0.0, 1.0)], [1, 2, 3, 4, 1]
 ))

but I'm not 100% sure about in general depending on what triangles you're encountering.

@rubenseyer
Copy link
Author

Thanks for the quick response (and sorry I didn't run that in time for you earlier)!
You correctly inferred that I meant a (possibly up to numerics) right triangle 😅
I stress-tested your fix with the outer generating code and it doesn't hang any more for me, so I consider this fixed for my purposes. Now I just have to convince Makie to bump their compat bounds from 1.0 so I can actually install the new version in the rest of the environment.

@DanielVandH
Copy link
Member

DanielVandH commented Oct 19, 2024

Great! I will make a new release with the fix.

Now I just have to convince Makie to bump their compat bounds from 1.0 so I can actually install the new version in the rest of the environment.

It should be all up to date on Makie's side as well. You probably have an outdated environment (use ]st --outdated to see what might be holding it back).

Unless you mean that 1.0 is making v1.6.1 of this package not able to be installed? That shouldn't be how it works - 1.0 means any versions in [1.0, 2.0) (i.e. just excluding 2.0).

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

2 participants