-
Notifications
You must be signed in to change notification settings - Fork 41
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
DelaunayTriangulation.DivideAndConquer sometimes loops forever/gets stuck #28
Comments
Thanks for the kind words and the report. I'll try to figure out what is happening exactly! |
Not sure if we necessarily need other test cases, but just in case it helps this also reproduces the issue: [ Point2 [38.5,3.5] :+ 0
, Point2 [67.0,33.0] :+ 1
, Point2 [46.0,45.5] :+ 2
, Point2 [55.5,42.0] :+ 3
, Point2 [36.0,25.0] :+ 4
, Point2 [76.5,12.0] :+ 5
, Point2 [29.0,26.5] :+ 6
, Point2 [55.0,10.5] :+ 7
] |
Actually maybe it would be useful to look at my example, since I've actually seen that hang 100% of the time |
Per noinia/hgeometry#28, occasionally DelaunayTriangulation.DivideAndConquer loops infinitely - in this case, I was able to consistently use the seed 127624940715530481, to generate a dungeon which had the following room centroids: [ Point2 [38.5,3.5] :+ 0 , Point2 [67.0,33.0] :+ 1 , Point2 [46.0,45.5] :+ 2 , Point2 [55.5,42.0] :+ 3 , Point2 [36.0,25.0] :+ 4 , Point2 [76.5,12.0] :+ 5 , Point2 [29.0,26.5] :+ 6 , Point2 [55.0,10.5] :+ 7 ] and cause delaunay triangulation to loop indefinitely (or at least longer than I cared to wait for). Given the size of our graphs switching to naive generation should be fine performance-wise, and avoids the infinite loop.
Thanks for reporting the specific testcase! What "real number type" (i.e. type 'r') are you using? If you are using Doubles or Floats you may want to try Rational numbers instead; some of the geometric predicates used don't go that well with floating point numbers (see also the README). |
they're Doubles. |
I don't necessarily need the exact right answers in this case - an approximation is fine - though I would like them within a reasonable amount of time 😄 |
Aha, interesting! I’ll try Rational and see if that helps. |
@patrickt Did the problem go away when you used Rationals? |
Just as a heads-up; I've been working on an implementation of an O(n log n) time algorithm to compute the convex hull in R^3 (see hgeometry-devel). That then will also give easy O(n log n) time algorithms for delaunay triangulation and Voronoi diagrams (in R^2). This could then be an alternative to the current implementation. In trying to deal with all sorts of degeneracies in the 3D CH properly this all has turned into some sort of yak-shaving project.... causing me to implement some stuff on symbolic computation, and reimmplement some geometric primitives. I'm hoping I'm close to the end of the tunnel for that one now though :). |
I’ve been working on a little project that uses
hgeometry
, and so far I’m loving the library. In using it, however, I’ve found some circumstances where the divide-and-conquer algorithm for Delaunay triangulation loops infinitely, such as when given these points:To reproduce:
git clone [email protected]:patrickt/voronoid.git
git checkout a2d95e00f4774b19b03c640442d7c52d3f871c49
cabal new-build
cabal new-run
Approximately 75% of the time, this will loop infinitely (or at least for a very long time). If it doesn’t, run it a few times.
I ran some profiling tests, and it appears to be stuck in
Data.Geometry.Ball.disk
. I’m new to the codebase so I wasn’t able to debug any further. For the time being I’m using theNaive
module, which is good enough for my purposes, but I figured you’d want a bug report.voronoid.prof.txt
The text was updated successfully, but these errors were encountered: