How to draw 2nd order Voronoi diagram in Matlab? - matlab

The Matlab function voronoi(x,y) gives the first order Voronoi diagram for the set of points $(x,y)$ e.g.
Can we use this function to draw a higher order such as 2nd order Voronoi diagram? By the order of a Voronoi diagram means the number of closest points. For example the regular Voronoi diagram is called first order because the cells have a single point that is closest to any place in the cell. A second order Voronoi diagram will have cells which are identified by the two closest points.
This previous question Higher order voronoi diagram discuss a similar problem but not in Matlab.

IMO you can use the closest pair of the sites and a dendogram and the k-order voronoi is an overlay of x k-order voronoi but without the intersecting edges.

Related

How can I visualise the 3D voronoi diagram in MATLAB?

I don't understand the documentation that describes the visualisation of voronoi regions in MATLAB.
the documentation says the following:
You can plot individual bounded cells of an N-D Voronoi diagram. To do this, use the convhulln function to compute the vertices of the facets that make up the Voronoi cell. Then, use patch or other plotting functions to generate the figure.
I have a set of 3D points (P) that I calculated voronoin for using [v,c]=voronoin(P)
What do I do next to visualise this ?
voronoin always generates a row of inf values in v. So how can I use v to generate/visualise the voronoi regions/diagram?
Thanks

Voronoi Regions

I'm facing issues when trying to create voronoi regions in MATLAB and handle infinite vertices. I am relatively inexperienced in programming which I feel is hampering my ability to solve this problem.
I want to trace specific locations near the central nodes of the voronoi sub-polygons using the function inpolygon. I can not utilise the function if one of the vertices is Infinite (INF). Therefore, I wanted to create a grid around the voronoi split (As seen in image), and only consider the region within this grid, thereby neglecting the infinite vertices.
What I have done so far:
I already have a certain 100 pairs of Latitudes and Longitudes of nodes, around which I create a voronoi split using voronoi(x_coordinates, y_coordinates) function.
When I have to determine the various coordinates of the sub-polygons within this split, I use the
[V,C] = voronoin([x_coordinates, y_coordinates]);
Till now, this gives me all the of voronoi regions in V and all indexes of vertices for all sub-polygons (voronoi regions) in C.
Then I have implemented a function which uses inpolygon and takes x and y coordinates of the point that has to be traced within one of the voronoi regions. And here is where I am stuck. I am trying to implement a grid all around, but can not find the new intersecting vertices of the grid and the voronoi sub-region to find the new vertices of the voronoi sub-polygons.
Also, if there is any other way to achieve the same task, any help would be highly appreciated.
Many Thanks.

How can I obtain Voronoi diagram on a Red Blood Cell using XYZ coordinate of points and face connectivity data from Delaunay triangulation?

UPDATE (1/12/14): Dear all, I have been trying all I can to code the algorithm by Dr Darren below in MATLAB but I am yet to succeed with it. I humbly request that a good Samaritan should kindly help me with the code and share the m-file. Thanks once again.
I intend to obtain Voronoi diagram on RBC using MATLAB/FORTRAN. I need the following specific information.
Voronoi vertex using the normal vector for each Delaunay triangle;
Order of each Voronoi polygon;
Voronoi vertex lists that define the Voronoi polygons;
Component of normals on the Voronoi polygons;
Areas of the Voronoi polygons;
Centroids of the Voronoi polygons;
Finally, plot Voronoi polygons using PATCH;
Please find link to corresponding text files RBC_1 which contain XYZ node coordinates on the RBC and RBC_2 which contain face connectivity data from Delaunay triangulation (RBC_1 and RBC_2 are in Zip file).
https://www.dropbox.com/s/slan053xbr2e864/RBC.zip?dl=0
I have tried to follow the work of John Burkardt for unit sphere: http://people.sc.fsu.edu/~jburkardt/m_src/sphere_voronoi/sphere_voronoi.html but its not working.
Thank you in advance.
N.B Any comment and advice will be highly appreciated.
Looking at your files, you have a set of points P in R^3 and a (2-manifold) surface triangulation T of your geometry:
This can easily be turned into a surface voronoi complex V by noting that the voronoi complex is dual to the underlying triangulation T. This means the following:
for each primary edge Ei in T there is a dual edge Vi in the voronoi complex.
for each primary node Pi in P there is a dual cell Vc in the voronoi complex.
Each dual edge in the voronoi complex spans between the centre of the circumballs of the triangles that are adjacent to the associated primary edge in the triangulation.
This duality implies the following algorithm for the construction of the voronoi complex:
calculate circumcentres CC for all triangles in T
for (all edges Ei in T)
find triangles [Ti,Tj] in T adjacent to edge Ei
push voronoi edge Vi between centres [CC(Ti),CC(Tj)]
associate edge Vi with voronoi cells associated with edge endpoints [Pi,Pj] in Ei
endfor
Putting this into practice gives the following voronoi complex for your mesh:
As others have pointed out, your question is very extensive, and I won't try to answer everything here.
I have made a set of dual mesh construction routines available here. Nonetheless, based on the slew of emails that you've bombarded me with over the weekend, let me make a few remarks: (i) you should invest some effort to understand a bit of computational geometry -- don't just blindly use the code provided, and (ii) if you do use the code provided, ensure that you make an effort to reference it appropriately.

Regarding Voronoi diagram

In MATLAB's function of Voronoi diagram, the vertices of edges at infinity are plotted at some distant point. Have a look at the first diagram on the page here. The first point from the top on Y-axis is (0,0.75). (Though it is extended beyond the bounds of the image). I know if I run the following matlab function:
[vx,vy]=voronoi(x,y)
I can get the coordinates of the vertices, but they will be beyond the bounds of the plot. Is there any way to get the coordinate in bounds of the plot (for example, (0,0.75) as mentioned above).
All you need is to detect which of the vx,vy crosses the axes (using find or logical conditions, find(vx<0) , find(vy>1) etc...) , and then apply the equation of the line y=a*x+b. For the point you wanted (which happens to be the 19th col of vx,vy, the slope a is:
a=diff(vy(:,19))/diff(vx(:,19));
and the intersection with y axis is given by b:
b=vy(1,19)-a*vx(1,19)
b =
0.7546
To calc b I picked the first point [vx(1,19),vy(1,19)] but this of course works also for the second point, i.e. b=vy(2,19)-a*vx(2,19)

how can combine two neighbour site(cell) in voronoi diagram?

How can I combine two neighbour site(cell) in voronoi diagram?
I decide in my project combine two neighbour site(cell) in voronoi diagram, can any one help me?
The dual Delaunay triangulation can be represented by a much simpler data structure. You can mark those triangle edges which are dual to the Voronoi edge you need to remove as invalid.