TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Voronoi Diagram and Delaunay Triangulation in O(nlog(n)) (2020)

109 pointsby cpp_frogover 1 year ago

9 comments

emmanueloga_over 1 year ago
One of my favorite renderings of this is in this article [1], that shows the relationship between the Delaunay triangulation, Voronoi diagram, a relative neighborhood graph (RNG) and the euclidean minimum spanning tree (EMSP) of a set of 2d points.<p>I have a theory that the union of the edges of the RNG and EMSP could be used for automatic navigation between widgets in a GUI: combining the two, there&#x27;s always between 1 and 4 edges coming out of every point, and so each of them could correspond to a direction key up&#x2F;down&#x2F;left&#x2F;right according to some simple heuristic.<p>--<p>1: <a href="https:&#x2F;&#x2F;axltnnr.io&#x2F;2018&#x2F;Triangulation&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;axltnnr.io&#x2F;2018&#x2F;Triangulation&#x2F;</a>
评论 #38019478 未加载
评论 #38010710 未加载
评论 #38010307 未加载
TomK32over 1 year ago
In case anyone wonders how a voronoi diagram looks on a wall, here&#x27;s my living room <a href="https:&#x2F;&#x2F;tomk32.de&#x2F;assets&#x2F;voronoi-wall.jpg" rel="nofollow noreferrer">https:&#x2F;&#x2F;tomk32.de&#x2F;assets&#x2F;voronoi-wall.jpg</a><p>The process to create it is as simple as you might think, select points, draw the center lines for all pairs of close neighbour points and the corners will appear naturally. Tape all edges and paint the wall starting with almost white, mix more of the three base colours into for each of the cells.
OskarSover 1 year ago
I wrote a moderately popular Delaunay&#x2F;Voronoi library for Unity a few years back [1] with a neat little demo video [2]. I implemented the incremental Bowyer-Watson algorithm for generating the triangulations, and then took the dual to generate the Voronoi tesselation (I also added a &quot;clipper&quot; that clips the voronoi diagram to a convex outline, which was fun, I haven&#x27;t seen that anywhere else before and had to figure out how to do it myself).<p>Bowyer-Watson (which is described in this article) seems very simple to implement when you start: just start with a &quot;big triangle&quot; and then add points iteratively to it, and perform the flips you need to do. To do it performant, you have to build up a tree structure as you go, but it&#x27;s not very tricky.<p>However: almost every description (including on Wikipedia) and implementation of Bowyer-Watson I could find was wrong. There&#x27;s an incredibly subtle and hard to deal with issue with the algorithm, which is the initial &quot;big triangle&quot;. Most people who implement it (and indeed I did the same initally) just make the triangle big enough to contain all the points, but that&#x27;s not enough: it needs to be big enough to contain all the points in all the circumcircles of the triangles. These circumcircles can get ENORMOUS: in the limit of three points on a line, it&#x27;s an infinite half-plane. Even if they aren&#x27;t literally collinear, just close, the triangle becomes way to huge to deal with.<p>The answer is that you have to put the points &quot;at infinity&quot;, which is a very weird concept. Basically, you have to have special rules for these points when doing comparisons, it&#x27;s really tricky and very hard to get right.<p>If I were doing this again, I wouldn&#x27;t use Bowyer-Watson, this subtlety is too tricky and hard to get right. Fortune&#x27;s sweep-line is more complex on the surface, but that&#x27;s the one I would go with. Or the 3D convex hull technique (which I also wrote a library for, by the way [3]).<p>[1]: <a href="https:&#x2F;&#x2F;github.com&#x2F;OskarSigvardsson&#x2F;unity-delaunay">https:&#x2F;&#x2F;github.com&#x2F;OskarSigvardsson&#x2F;unity-delaunay</a><p>[2]: <a href="https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=f3T5jtsokz8">https:&#x2F;&#x2F;www.youtube.com&#x2F;watch?v=f3T5jtsokz8</a><p>[3]: <a href="https:&#x2F;&#x2F;github.com&#x2F;OskarSigvardsson&#x2F;unity-quickhull">https:&#x2F;&#x2F;github.com&#x2F;OskarSigvardsson&#x2F;unity-quickhull</a>
评论 #38017160 未加载
omoikaneover 1 year ago
My favorite algorithm for generating Voronoi diagrams is the Jumping flood algorithm:<p><a href="https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Jump_flooding_algorithm" rel="nofollow noreferrer">https:&#x2F;&#x2F;en.wikipedia.org&#x2F;wiki&#x2F;Jump_flooding_algorithm</a><p>This is an approximate algorithm that only works in pixel space, but it&#x27;s lots of fun to implement (simpler to implement than Fortune&#x27;s algorithm).
评论 #38015294 未加载
评论 #38012587 未加载
raphlinusover 1 year ago
The numerical robustness thing gave me a chuckle (rotate 1 radian and pray to the geometry gods), especially as I&#x27;ve been spending a good fraction of my time dealing with that in fancy path rendering and stroking.<p>One of the things I really want to work on in the next few months is a path intersection implementation that&#x27;s robust by construction, backed up both by a convincing (if not formal) argument and tests crafted to shake out robustness issues. I have a bunch of ideas, largely motivated by the need to generalize well to curves - Shewchuk&#x27;s work, cited elsethread, is impressive but I&#x27;m not smart enough to figure out how to make it work for arbitrary Béziers.<p>There&#x27;s an issue[277] to track the work, and that has pointers to some of the ideas. If anyone is interested in working with me on this, please get in touch. If successful, I think it&#x27;ll result in a nice code base and also likely a publishable paper.<p>[277]: <a href="https:&#x2F;&#x2F;github.com&#x2F;linebender&#x2F;kurbo&#x2F;issues&#x2F;277">https:&#x2F;&#x2F;github.com&#x2F;linebender&#x2F;kurbo&#x2F;issues&#x2F;277</a>
loehnsbergover 1 year ago
Unfortunately, as you move into higher dimensions, these algorithms typically bog down.<p>Suppose that you have a point that is inside of the convex hull of the mesh that you want to use for triangulation (we‘re talking hyper-triangles here). What are the best points to choose for your triangulation? Since there are a lot of candidates for hyper-triangles you cannot possibly store the set of triangles beforehand.<p>I approached this problem using linear programming using the distance to the mesh points to find the best triangle. Not sure if this is the best approach though.<p>Happy to hear if someone knows of a better approach.
评论 #38010687 未加载
lispisokover 1 year ago
A new weather model NCAR is working on uses Voronoi meshes to divide the planet into cells. The Voronoi meshes allow nice transitions of higher resolution to lower resolution cells so you can model at higher resolutions in areas of interest and dont have the same problems the WRF and GFS have trying to divide a sphere into square cells<p><a href="https:&#x2F;&#x2F;ncar.ucar.edu&#x2F;what-we-offer&#x2F;models&#x2F;model-prediction-across-scales-mpas" rel="nofollow noreferrer">https:&#x2F;&#x2F;ncar.ucar.edu&#x2F;what-we-offer&#x2F;models&#x2F;model-prediction-...</a> <a href="https:&#x2F;&#x2F;mpas-dev.github.io&#x2F;" rel="nofollow noreferrer">https:&#x2F;&#x2F;mpas-dev.github.io&#x2F;</a>
ginkoover 1 year ago
I would be interested in an explanation why it&#x27;s O(nlog(n)).<p>It requires sorting the points along one axis which already gives O(nlog(n)) as a lower bound, but I&#x27;d be interested in how the line-sweeping would need to be done to not go over that.<p>The number of points in the beach front should roughly scale with the square root of points, so a naive search&#x2F;replace per point insertion would take sqrt(n) operations and a O(n*sqrt(n)) overall runtime.
评论 #38011830 未加载
评论 #38010600 未加载
ad-astraover 1 year ago
Wow literally just what I needed to see for a project I’m working on, I love hacker news!
评论 #38010426 未加载
评论 #38009808 未加载