-1

Dear Community Members,

I’ve been working recently on Delaunay triangulation implementation in cpp. While I’ve algorithm that works.. it’s terribly slow (100 objects are computed in about ~16 seconds).

Algorithm is basing on brute force approach. Given a finite set of points:

  • I’m iterating through each points three times, checking, if I can
    create a triangle from those points;
  • From those three points, I’m creating circle, that goes through those points;
  • I’m iterating through whole set of points fourth time, checking if created circle, contains any point different from those three mentioned above.
  • If no additional points are within circle, I assume that triangle created from those three points is valid.

Like I mentioned, algorithm is direct implementation of on Delaunay triangulation described here: https://en.wikipedia.org/wiki/Delaunay_triangulation. It’s working “flawlessly” but its slow.

Any ideas/suggestions about logic that could speed it up (if possible, without changing logic entirely)?

  • 1
    You'll have to change the logic if you want acceptable speed. Whatever trick you use, n^4 is going to be very slow, sensible algorithms are n log n. – Marc Glisse Apr 06 '17 at 08:16
  • could you have a predefined set of circles for some range of triangles. Then just see if your points match one of these – ldgorman Apr 06 '17 at 08:16
  • 2
    I'm going to give a general tip that too few people know: You don't need to take the square root when checking if a point is in the circle. – Jay Apr 06 '17 at 08:20
  • 1
    That page lists four algorithms. How about trying one of those? – molbdnilo Apr 06 '17 at 08:37
  • also the bottleneck is usually in wrong lists usage with too much reallocations or insert movements ... resulting in even much much worse complexity .... – Spektre Apr 06 '17 at 08:47

1 Answers1

-1

Thank You all for quick feedback.

I’ve done some additional research and sadly, it seems the most optimal way to reduce time complexity is to rewrite existing algorithm entirely.

For others who could have similar issues, sample approaches are described here: https://people.eecs.berkeley.edu/~jrs/274/proj.html