This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.


Class: DelaunayTri

(Not recommended) Point closest to specified location


nearestNeighbor(DelaunayTri) is not recommended. Use nearestNeighbor(triangulation) instead.

DelaunayTri is not recommended. Use delaunayTriangulation instead.


PI = nearestNeighbor(DT,QX)
PI = nearestNeighbor(DT,QX,QY)
PI = nearestNeighbor(DT,QX,QY,QZ)
[PI,D] = nearestNeighbor(DT,QX,...)


PI = nearestNeighbor(DT,QX) returns the index of the nearest point in DT.X for each query point location in QX.

PI = nearestNeighbor(DT,QX,QY) and PI = nearestNeighbor(DT,QX,QY,QZ) allow the query points to be specified in column vector format when working in 2-D and 3-D.

[PI,D] = nearestNeighbor(DT,QX,...) returns the index of the nearest point in DT.X for each query point location in QX. The corresponding Euclidean distances between the query points and their nearest neighbors are returned in D.


nearestNeighbor is not supported for 2-D triangulations that have constrained edges.

Input Arguments

DTDelaunay triangulation.
QXThe matrix QX is of size mpts-by-ndim, mpts being the number of query points and ndim the dimension of the space where the points reside.

Output Arguments

PIPI is a column vector of point indices that index into the points DT.X. The length of PI is equal to the number of query points mpts
DD is a column vector of length mpts.


Create a Delaunay triangulation:

x = rand(10,1);
y = rand(10,1);
dt = DelaunayTri(x,y);
Create query points:
qrypts = [0.25 0.25; 0.5 0.5];
Find the nearest neighbors to the query points:
pid = nearestNeighbor(dt, qrypts)

Was this topic helpful?