Voronoi from delaunay triangulation - 2d

I have almost finished my Delaunay / Voronoi triangulator and it was hard.
I haven't used the Fortun's code, I created the Delaunay triangulator and I derive the Voronoi diagram from that.
There is a problem though; infinite lines. I cannot find a method to define the Voronoi cells delimited by those infinite lines, I have tried almost anything.
Any suggestion?

To fix the infinite lines, just add an extra vertex at infinity where they all meet. From here, you just do the usual dual map, taking faces <-> verts. That's it.

Related

How to use delaunay trianglation in 3d points?

I understand how to use delaunay triangulation in 2d points?
But how to use delaunay triangulation in 3d points?
I mean I want to generate surface triangle mesh not tetrahedron mesh, so how can I use delaunay triangulation to generate 3d surface mesh?
Please give me some hint.
To triangulate a 3D point cloud you need the BallPivoting algorithm: https://vgc.poly.edu/~csilva/papers/tvcg99.pdf
There are two meanings of a 3D triangulation. One is when the whole space is filled, likely with tetrahedra (hexahedra and others may be also used). The other is called 2.5D, typically for terrains where the z is a property as the color or whatever, which doesn't influence the resulting triangulation.
If you use Shewchuk's triangle you can get the result.
If you are curious enough, you'll be able to select those tetrahedra that have one face not shared with other tetrahedra. These are the same tetrahedra "joined" with infinite/enclosing points. Extract those faces and you have your 3D surface triangulation.
If you want "direct" surface reconstruction then you undoubtly need to know in advance which vertices among the total given are in the surface. If you don't know them, perhaps the "maxima method" allows to find them out.
One your points cloud consists only of surface vertices, the triangulation method can be any one you like, from (adapted) incremental Chew's, Ruppert, etc to "ball-pivoting" method and "marching cubes" method.
The Delaunay tetrahedrization doesn't fit for two reasons
it fills a volume with tetrahedra, instead of defining a surface,
it fills the convex hull of the points, which is probably not what you expect.
To address the second problem, you need to accept concavities, and this implies that you need to specify a reference scale that tells what level of detail you want. This leads to the concept of Alpha Shapes, which are obtained as a subset of the faces.
Lookup "Alpha Shape" in an image search engine.

Is triangle rasterization possible without baryzentric coordinates?

Im just planing a triangle rasterizer on GPU (GLSL) and I came across an algorithm that could remove barycentric coords (which is quiet expencive to copute) from rasterization.
Given the triangle ABC with the edges abc and the linear equation f.
In the first step I check each of the edges abc for intersection with f, (the triangle is already projected in R²)
then I take the factor from the linear equation of abc (each edge is an linear equation) and use this parameter in R³ for determinating a new equation which conects the two intersection points on two differnt edges of the triangle.
So now I can fill my triangle line by line (the pixels between the intersection points are filled).
Based on the linear equation in R³ (of the intersection points) I can now determinate the R³ cooeds of each pixel so I have a depth value.
I know it's a bit complicated so if you have any quaestion please ask me.
So do you think it's possible this way and if yes, is iit faster ??
If I forgot anything or if I did a mistake please inform me.
If you have any optimisation idea or something else please inform me.
I found out that it is a bit faster but I'll have some problems with textures and additionsl calculations would slow the whole thing so I think I will use barycentric coordinates.

Cluster adjacent Vornoi polygons of same category

We have a set of points, each with (x,y) coordinates and a category C. We have built the Voronoi diagram based on these points and would now like to "cluster" adjacent polygons when they are of a particular category. Is there a ready-made algorithm / R package for doing this ?
If not, our current thinking is to go back to the Delaunay triangulation and brute-force our way to the solution : consider each vertix V, find the vertix v of each edge going into V and see if they are the same category, if so aggregate the polygons.
Is there a better way to do that ? Is there an R package that could do that ? If not, which R package implementing Delaunay would have the best result data-structure to do this ?
Note: I wouldn't call this cluster analysis. If you stick to this keyword, you will not find anything useful to you. What you apparently want to do is merge adjacent Voronoi cells, but that's about it.
Your Voronoi cell / Delaunay triangulation algorithm should give you information of all the edges. What you probably want to do is iterate over all edges, and when both cells have the same category, merge them.
Trivial code; and heavily application dependant (what is "same category"?), so you probably won't find a "libary" for it.
You can use a convex hull on the points and remove all points inside a same category. Then repeat the voronoi diagram. BTW. I know nothing about R.

Voronoi diagram using custom (great circle) distance

I want to create a Voronoi diagram on several pairs of
latitudes/longitudes, but want to use the great circle distance
between them, not the (inaccurate) Pythagorean distance.
Can I make qhull/qvoronoi or some other Linux program do this?
I considered mapping the points to 3D, having qvoronoi create a 3D
Voronoi diagram[1], and intersecting the result with the unit sphere, but
I'm not sure that's easy.
[1] I realize the 3D distance between two latitudes/longitudes (the
"through the Earth" path) isn't the same as the great circle distance,
but it's easy to prove that this transformation preserves relative
distances, which is all that matters for a Voronoi diagram.
I assume you've found this article. From that, it seems like you have the right idea by using a 3D embedding. Your question is then how to intersect the result with the sphere.
First of all you need to consider how you're going to represent the voronoi diagram. If you want to work in lat/long coordinates in a 2D plane, then your voronoi diagram will contain curved edges, so maybe it is best to just use a 3D representation.
If you use a program like qvoronoi, you should in theory only need the inifinite hyperplane data (generated by Fo). This gives you the equation of the plane and the two points it corresponds to. Usually you only need to use the voronoi diagram to test for inclusion within regions, and the hyperplanes should be enough for that.
See also this question: Algorithm to compute a Voronoi diagram on a sphere?

How do I cut triangles out of a concave Delaunay triangulation?

I'm using Delaunay to triangulate a concave polygon, but it fills in the concavities. How do I automatically remove the triangles that are outside the polygon boundaries?
Self-answer: in some cases, this is impossible. I needed to use a constrained Delaunay algorithm: http://www.cs.cmu.edu/~quake/triangle.delaunay.html
You shouldn't, you should find a Delauney routine that handles boundaries correctly.
Alternately you could, assuming you know the edges, go through every triangle and delete those that cross an edge.
Search for segment-segment interestion tests for code to do this.

Resources