Determine nearest alpha shape boundary point
Nearest Alpha Shape Boundary Point
Create a set of 2-D points.
th = (pi/12:pi/12:2*pi)'; x1 = [reshape(cos(th)*(1:5), numel(cos(th)*(1:5)),1); 0]; y1 = [reshape(sin(th)*(1:5), numel(sin(th)*(1:5)),1); 0]; x = [x1; x1+15]; y = [y1; y1];
Create and plot an alpha shape with alpha radius equal to 1.
shp = alphaShape(x,y,1); plot(shp) hold on
Compute the nearest
shp boundary point to the query point
QP. Plot the query point in blue and the nearest boundary neighbor in red.
QP = [6 3]; plot(QP(1),QP(2),'b.','MarkerSize',10) hold on I = nearestNeighbor(shp, QP); plot(shp.Points(I,1),shp.Points(I,2),'r.','MarkerSize',10)
qx — Query point x-coordinates
Query point x-coordinates, specified as a numeric array.
qy — Query point y-coordinates
Query point y-coordinates, specified as a numeric array.
qz — Query point z-coordinates
Query point z-coordinates, specified as a numeric array.
QP — Query point coordinates
two-column matrix | three-column matrix
Query point coordinates, specified as a two-column matrix or a three-column matrix.
For 2-D, the columns of
For 3-D, the columns of
I — Nearest neighbor indices
Nearest neighbor indices, returned as an integer-valued array. The indices
correspond to the row index of
shp.Points and indicate
the points on the boundary of
shp that are closest to the
given query points.
D — Distance from query points to nearest neighbors
Distance from query points to nearest neighbors, returned as a numeric
D is the 2-D or 3-D Euclidean distance and is the
same size as
Introduced in R2015a