Voronoi polygons distance between points

3 visualizzazioni (ultimi 30 giorni)
giometar
giometar il 26 Giu 2019
Commentato: giometar il 9 Lug 2019
Hello
I have set of 2D points and after creation of voronoi polygons I want to calculeate distance between poit from one polygone and all neighborhood points (as in picture). Blue dots are my 2D points

Risposta accettata

Matt J
Matt J il 26 Giu 2019
Modificato: Matt J il 26 Giu 2019
This returns the result as a distance matrix such as produced by pdist2, except that all entries not corresponding to neighboring points are set to NaN. Neighbors are defined as points whose Voronoi polygons share one or more (finite) vertices.
[V,C]=voronoin(points);
F=all(isfinite(V),2);
D=pdist2(points,points);
D(~common_vertex(C,F))=nan, %the result
function map = common_vertex(C,F)
n=numel(C);
map=false(n);
for i=1:n
for j=1:i-1
map(i,j)=any( F(intersect(C{i},C{j})) );
end
end
map=logical(map+map.');
map(1:n+1:end)=1;
end
  4 Commenti
Matt J
Matt J il 4 Lug 2019
Modificato: Matt J il 4 Lug 2019
hope that is correct way
Only you can know if it serves your needs, but I'm not sure it is equivalent to the neighborhood analysis you were originally pursuing. It assumes that points belonging to a common Delaunay triangle always occupy neighboring Voronoi poygons, and I'm not sure that's true.
giometar
giometar il 9 Lug 2019
that is the reason why I wrote "hope that is correct way"
I use both ways, to be sure that results are good :-)

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Voronoi Diagram in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by