Search code examples
juliadelaunay

Julia Delaunay triangulation hangs indefinitely


I am trying to get to grips with Delaunay triangulation in Julia. I am trying the following test code.

using VoronoiDelaunay
a = Point2D[Point(rand(),rand()) for i in 1:6]
tess = DelaunayTessellation()
push!(tess,a)

On inputting the final command into the REPL, the code seems to hang indefinitely. I have tried several times now and left it running for a long time, but at no point has it finished. Does anyone know if I am doing something wrong?


Solution

  • It looks like the VoronoiDelaunay package currently limits input points to a range of [1 + eps, 2 - 2*eps]. I was able to get your code to run with this change:

    a = Point2D[Point(1 + rand(),1 + rand()) for i in 1:6]
    tess = DelaunayTessellation()
    push!(tess,a)
    

    Following the example in their README, you can also use the built-ins max_coord and min_coord, which should be more robust than my first attempt:

    width = max_coord - min_coord
    a = Point2D[Point(min_coord + rand() * width, min_coord + rand() * width) for i in 1:6]
    

    Note I'm assuming you meant DelaunayTesselation as DelaunayTriangulation does not appear to be a method provided by the package.

    My result:

    enter image description here