Algorithm for the reduction of a Triangulation - algorithm

I've computed a triangulation of a region, which boundaries are described by a polygon. But the triangulation is computed for the convex hull, bigger than the region.
Some of the triangles in the resulting set must be discarded. Dou you know about an algorithm for this operation?

I would combine this (triangulation of the convex hull) with another algorithm which would check if a given point is inside the polygon or not. Then, for each resulting triangle, I would check if it's median point is inside the polygon.

If you can use a 3rd party library, you can use CGAL and the following example will do what you want (including the triangulation).

You can try alpha shapes. Its delaunay triangulation without edges exceeding alpha.

Related

Build constrained alpha shape of polygons

I have a quite specific task.
I need to compute alpha shape of a set of points. (You can frolic with already implemented algorith there)
The point is that I have predefined subsets of points (let's call them details) and I do not want their structure to be changed. For example, suppose these polygons to be details:
Then, the following hulls are ok depending on alpha-radius:
And the following is not:
In brief, I want the structure of specified subsets of points to stay unchanged during reducing the radius.
So, how do you think:
May I use any of already implemented algorithm or should I figure out some specific one?
Is there implemented example of Alpha-Shape algorithm with open source code anywhere? (Alpha-Shape, not Concave hull. It must split contour into several parts when reducing the radius)
Well, Finally I solved this using constrained Delaunay triangulation.
The idea (that Yves Daoust shared in comment to the question) was to use not just Delaunay triangulation during building Alpha shape, but constrained Delaunay triangulation.
Algorithm: In brief, I:
Took convex hull of the promoted polygons
Computed its constrained triangulation. (Constraining segments are polygon's edges)
On this step I used Triangle .NET library for C#. I guess, every popular language has alternatives to it.
Built alpha shape: threw away all triangles where any edge is longer than predefined alpha
Results of my struggles:
Alpha = 1000, alpha shape is just a convex hull
Alpha = 400
Alpha = 30. Only very small concavities are smoothened
Feel free to write me for a deeper explanation, if you wish.

Voronoi site points from Delaunay triangulation

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.

Get the polygon created by moving a polygon

I don't know if the process has a specific name. I want to get the polygon which is created by translating a polygon. Is there an algorithm for this. For example:
.
Convex hull works for convex polygons but I want a general solution. Also I would be happy to hear if there is a way to get the polygon created by rotating.
It appears you are looking for the Minkowski sum of your polygon and the line segment describing your movement.
The CGAL library package 2D Minkowski Sums can compute them for instance.
Given the explanation you gave in comments, the straightforward approach is this:
Let v be a vector describing the linear movement
For each edge (p,q) in the polygon
construct quadrilateral (p, q, q+v, p+v)
Compute the union of all the quadrilaterals plus the original polygon
Computing polygon unions is a well-studied problem with efficient algorithms.

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.

Delaunay triangulation from convex hull

I need to write some codes on computational geometry and parallelize them using openMP.So far, I have finished convex hull and closest pair of points.I need to write the delaunay triangulation divide and conquer code.But I dont have much time.I read somewhere that delaunay triangulation can be easily implemented if the convex hull can be calculated.So if anyone can provide me the serial code for DT or atleast let me know how i could generate the delaunay triangulation from convex hull, i could write the code and parallelize it as soon as possible.
I read somewhere that delaunay triangulation can be easily implemented if the convex hull can be calculated.
This is true, but the precise statement is that the 2D Delaunay triangulation can be easily constructed if a 3D convex hull implementation is available. Knowing the 2D hull does not help much with constructing the Delaunay triangulation (DT), besides giving you a few edges of the DT (each hull edge is an edge of the DT).
Assuming you have not implemented the 3D hull (which is quite tricky), then you need to attack
the Delaunay triangulation separately.
QHull is pretty much the standard library many people use: http://www.qhull.org/html/qhull.htm
Perhaps you can use it as a reference implementation, if you really want to reimplement this.

Resources