Voronoi site points from Delaunay triangulation - algorithm

How can one determine the exact Voronoi sites (cells/regions) from a Delaunay triangulation?
If one has an already constructed delaunay triangulation it is easy to calculate the edges of a voronoi by simply connecting adjacent circum-circle centers of every triangle.
It is also easy to determine the Voronoi points/sites because they are represented by every point of every triangle in the Delaunay triangulation.
However how do you determine that a specific voronoi site goes with a specific list of edges from a delaunay triangulation?
It seems it is simple to get one and the other as separate entities but putting them together is another challenge?
Looking at the diagram below, you can see the Delaunay triangulation along with the dual Voronoi diagram. All that I described can be pictured below for an easy reference. Ignore the green circle as that is just an artifact of this particular reference i took from the web.

If you want polygons from edges pick the midpoint of each edge and the distance to each site then sort the result and pick the first and second (when they are equal) and save them into polygons. For the borders there is of course only 1 edge. Maybe a dupe:Getting polygons from voronoi edges.
It's a bit tricky and hard to visualize. I am little stuck with the borders. Here is the original answer from Alink:How can I get a dictionary of cells from this Voronoi Diagram data?.

Each vertex in the Delaunay triangulation represents a Voronoi site. So to create the cell of a site you take one such triangle t and a vertex v in t. Now compute the Voronoi edges between v and the two remaining vertices of t. Repeat this process by traversing the triangles around v one by one. Assuming you can store the neighbourhood relation between the triangles this should at most take O(k) time, k being the number of adjacent triangles of v.
This converts the Delaunay triangulation into the Voronoi Diagram in O(n) time/space, for n sites. No sorting is required, otherwise what is the point in having the Delaunay triangulation in the first place.

Related

Produce a random Voronoi diagram with a specific length and width?

A Voronoi diagram is an approach to the tessellation of medium.
In this diagram, there are many points in a plane that divide the medium to many specific regions by their bisector. Any region is convex and has a circumscribed rectangle.
The circumscribed rectangle of convex shape that has the smallest area (We have an algorithm to imagine any edge on the direction of a specific edge and perpendicular to edge and find a rectangle with the smallest area.).
I want to place the points in a way that creat random convex polygons (Random means have different numbers of edges.).
But I want to control the size of the width and length of their circumscribed rectangle.
So I want to know is there any algorithm for the locating points with the above property?
Although I could not entirely follow your question note that Voronoi polygons have a strong combinatorial structure, so you should be careful what kind of "randomness" you expect for the number of Voronoi polygon edges.
Some more details: Since the Voronoi diagram is a planar graph with V Voronoi nodes, E Voronoi edges and F Voronoi polygons, you have
V - E + F = 2
due to Euler's formula. (Though, there is some technical detail with a vertex at infinity where all infinitely long Voronoi edges and unbounded Voronoi polygons meet.) Next, unless four of more input points would happen to lie on a circle, we have typically three Voronoi edges meeting at a Voronoi node, and therefore
3V = 2E
which gives
E = 3F - 6.
(Again, there is this technical detail with infinite Voronoi edges/polygons. If you have more than three infinite Voroni edges/polygons, say E', then you would have correct it to E = 3F - 3 - E'.)
Without going into too much detail, a "typical" Voronoi polygon actually has 6 edges. (Its dual graph is the Delaunay triangulation, so the dual assertion is that a vertex in the Delaunay triangulation has typically 6 triangulation edges incident.)
If you want to be more "flexible" on the number of edges then more than three Voronoi edges need to meet on a Voronoi node and therefore more than three input points need to be corcircular. Note that these circles are centered at the Voronoi nodes and in this sense you can even compute the number of such circles you need given the number F of Voronoi polygons and number E of Voronoi edges by Eulers formula:
V = 2 + E - F.
I hope this helped in getting a feeling on how Voronoi diagrams behave.

Is there any algorithm for covering a concave polygon(contains holes) with convex polygons

This can be approached in two ways :
i) by partitioning the given polygon into convex polygons such that there is no
overlap between the convex polygons
ii) by covering the given polygon using convex polygons such that their union
gives the original polygon. In this case there can be overlap between
the convex polygons
Although partitioning covers the entire polygon, number of convex polygons can be reduced by second approach. It is also known that covering a concave polygon(second approach) with minimal number of convex polygons is NP-Hard.
I'm specifically looking for algorithms based on second approach mentioned above,but number of convex polygons may not be minimal.
As already mentioned by MBo and Yves Daoust in the comments to your questions. Polygon decomposition into convex polygons can be done by triangulation (or trapezoidal decomposition). This will result for an n vertex simple polygon P with n-2 (interior) triangles, i.e., is linear in the number of vertices.
Another way to construct a convex decomposition would be to use a generalized motorcycle graph. I would assume there must be a simpler way though!
The main idea is to start a motorcycle m for every reflex vertex r in P. Every motorcycle m drives with a given speed in a given direction and leaves a trace behind. If another motorcycle meets such a trace it crashes, i.e., stops but leaves the trace.
Generalized refers to the embedding in P and that the polygon boundaries function as walls where the motorcycles also crash. Furthermore if two motorcycles meet at the same point we have to start another one, or in this case just continue with one and stop the other. After all motorcycles have crashed there is the graph of the traces which in fact is a convex tessellation of P. There are several papers (one here) on this but implementation would be tough. This results in O(r) convex polygons that cover the interior of P.
I think the easiest way is to go with the triangulation or trapezoidal decomposition. These are well studied and available as implementation in many libraries.
Also mentioned in the comments: Input can be produced that will force O(n) polygons. Just think of a star shaped polygon that has n/2 reflex vertices (interior angle > pi).

Confusion on Delaunay Triangulation and Largest inscribed circle

I need to find a largest inscribed circle of a convex polygon, I've searched many sites and I get that this can be done by using Delaunay triangulation. I found a thread in CGAL discussion with an algorithm using CGAL:
You can compute this easily with CGAL:
First, compute the Delaunay triangulation of the points.
Then, iterate on all the finite faces of the triangulation.
For each finite face f
compute its circumcenter c
locate c in the triangulation (to speed up things, you can give one
vertex of f as starting hint for the point location)
if the face returned by locate(c,hint) is finite, then the circumcenter
c lies in the convex hull of the points, so, f is a candidate
if f is such a candidate face, compute its squared circumradius
keep only the face with minimum squared circumradius
The CGAL manual (chapter 2D triangulation, together with a few things
from the kernel) shows every basic function to do this.
I was a bit confused with the last part of this algorithm. When I read it what I understand from it is that the minimum circumradius of the triangulation face is the radius for the largest inscibed circle. But from examples of polygon with Delaunay triangulation, it seems that even the smallest circumcircle sometimes cannot fit inside the polygon, so how can this has the same radius as the largest inscribed circle?
Maximum inscribed circle in polygons.
The classical computational-geometry solution to the maximum inscribed circle problem for polygons is to use the generalized Voronoi diagram of the polygon's faces resp. the medial axis of the polygon. This approach works in a more general setting like polygons with holes, see this stackoverflow answer to a similar question.
Convex input.
The convexity of your input polygon, however, gives the problem more structure, which I would like to comment on. Consider the following convex input polygon (black), the Voronoi diagram (blue), and the maximum inscribed circle (green) centered on a Voronoi node.
The classical Voronoi-based solution is to (i) compute the Voronoi diagram and (ii) take the Voronoi node with largest clearance (i.e., distance to its defining faces).
The Voronoi diagram of a polygon with holes (i.e., the set of vertices and edges) can be computed in O(n log n) time, c.f. Fortune's algorithm (1986). Later Chin et alii (1999) gave an O(n) algorithm for the medial axis of a simple polygon.
For convex polygons, however, a time-optimal algorithm for Voronoi diagram that runs in O(n) time was already known in 1989 due to Aggarwal et alii. This algorithm follows basically the following idea: Consider the grey offset curves moving inwards at unit speed. If you project this movement into three-space where the z-axis is time you get a unit-slop roof over the polygon:
This roof model could also be characterized as follows: Put a half-space on each polygon edge at 45° slope with polygon (such that they contain the polygon) and intersect them all. So if you can quickly compute the intersect of half-spaces then you can also quickly compute Voronoi diagrams of convex polygons. Actually, for the maximum inscribed circle problem we do not need to go back to the Voronoi diagram but take the one peak of the roof, which marks the center of the maximum inscribed circle.
Now the half-spaces are dualized to points, and then the intersection of half-spaces corresponds the convex hull of its dual points. Aggarwal et al. now found an O(n) algorithm for the convex hull of points that stem from this setting.
A summary of this construction that leads to a Voronoi diagram algorithm for convex polyhedra in any dimension can be found in a blog article of mine.
Simple & fast implementation. A simpler algorithm to compute the Voronoi diagram is motivated by straight skeletons. For convex polygons the Voronoi diagram and the straight skeleton are the same.
The algorithm behind the straight-skeleton implementation Stalgo basically simulates the evolution of the wavefront structure (the grey offset curves). For convex polygons this reduces to finding the sequence of edges that collapse.
So a simple O(n log n) algorithm could look like this:
Construct a circular list of the polygon edges. Compute the collapse time of each edge during wavefront propagation, and insert this event into a priority queue.
Until the queue is empty: Take out the next edge-collapse event: Remove the edge from the circular structure and update the collapse times of the neighboring edges of the removed edge.
Actually, you can simplify the above algorithm further: You do not need to update edge collapses in the priority queue but simply insert new ones: Since the new collapse time of edges are strictly lower, you always get the right event first and dismiss the others and the queue is not growing larger than 2n. Hence, you do not compromise the O(n log n) time complexity.
For the maximum inscribed circle problem you can simplify the above algorithm even further: The Voronoi node (resp. straight skeleton node) you look for is due to the collapse of the final triangle at the end of the loop over the priority queue.
This algorithm should be quick in practice and only a few lines of code.
The last step can mean to select the minimum face of the triangle. Then rinse and repeat.

Determine which Delaunay edge is Gabriel

My purpose is to implement the algorithm to check whether a Delaunay edge is Gabriel.
As the definition, a Delaunay triangulation edge is said to be a Gabriel edge if its diametrical circle is empty. So, to check whether it is a Gabriel edge or not, we need to scan through all finite vertices in Delaunay to check if any is in that diametrical circle OR we just need to check on its 2 adjacent triangles. Which is the accurate option?
You only need to check the two adjacent triangles. Suppose the third vertex on one of the neighboring triangles is not inside the diametral ball of an edge (i.e., it suggests that the edge may have the Gabriel property). The empty (by the Delaunay property) circumcircle of this triangle (dashed below) contains a semi-circle corresponding to the Gabriel ball (in gray below). If you check both Delaunay triangles attached to an edge, you know that both halves of the Gabriel ball are empty.

How to convert a polygon to a set on non-overlapping triangles?

I have a coordinate set of 2D points that form a closed polygon. I need to generate a set of 2D triangles that distribute the polygon completely.
There are no constrains as such except that the triangles should fill the area of polygon completely. It would be even more helpful if it is a standard algorithm I could implement.
The best way to triangulate general polygons is to compute the constrained Delaunay triangulation - this is a standard Delaunay triangulation of the polygon vertices with additional constraints imposed to ensure that the polygon edges appear in the triangulation explicitly. This type of approach can handle any type of polygon - convex, concave, polygons with holes, etc.
Delaunay triangulations are those that maximise the minimum angle in the mesh, meaning that such a triangulation is optimal in terms of element shape quality.
Coding a constrained Delaunay triangulation algorithm is a tricky task, but a number of good libraries exist, specifically CGAL and Triangle. Both these libraries implement an (optimally) efficient O(n*log(n)) algorithm.
As mentioned above, Delaunay triangulation is a rather complicated algorithm for this task. If you accept O(n^2) running time, you may try Ear Clipping algorithm which is much more easier to understand and to code. The basic idea is the following. Every polygon with >= 4 vertexes and no holes (i.e. its border is a single polyline without self-intersections and self-tangencies) has at least one "ear". An ear is a three consecutive vertexes such that the triangle built on them lies inside the polygon and contains no other points of the polygon inside. If you "cut an ear" (add a triangle to the answer and replace remove the middle point of these three points), you reduce the task to a polygon with less vertexes, and so on. Ears may be trivially (by definition) found in O(n^2) resulting in a O(n^3) triangulation algorithm. There is O(n) ear finding algorithm, and, though it is not very complicated, it is rather long to be described in a couple of phrases.
Furthermore, if you need faster algorithms, you should look something about monotone polygons triangulation and splitting a polygon into monotone ones. There even exists a linear-time triangulation algorithm, but its just as complicated as Delaunay triangulation is.
You may consider Wikipedia article and see an small overview of existing methods there.
If you don't require that the vertices of the triangles be vertices of the polygon, try a triangulation based on a trapezoidal decomposition, as in Fast Polygon Triangulation based on Seidel's Algorithm.

Resources