N = neighbors(TR,ti)
N = neighbors(TR)
N = neighbors(TR) returns the neighbors of all the triangles or tetrahedra.
Triangle or tetrahedron IDs, specified as a column vector.
IDs of the neighboring triangles or tetrahedra, returned as a matrix. The elements in TN(i,:) are the neighbors associated with ti(i).
By convention, TN(i,j) is the neighbor opposite the jth vertex of ti(i). If a triangle or tetrahedron has one or more boundary facets, the nonexistent neighbors are represented as NaN values in TN.
A row number of the matrix, TR.ConnectivityList. Use this ID to refer a specific triangle or tetrahedron.
A row number of the matrix, TR.Points. Use this ID to refer a specific vertex in the triangulation.
Create a Delaunay triangulation from a set of random points.
x = gallery('uniformdata',[10,1],0); y = gallery('uniformdata',[10,1],1); DT = delaunayTriangulation(x,y);
Find the neighbors of the first triangle.
TN = neighbors(DT,1)
TN = NaN 4 5
The first triangle has a boundary edge and two neighbors.
Examine the vertex IDs of the first neighbor, TN(2).
ans = 2 4 7
Create the Delaunay triangulation.
load tetmesh TR = triangulation(tet,X);
Find the neighbors to each triangle in the triangulation.
TN = neighbors(TR);
Find the neighbors of the fifth tetrahedron.
ans = 2360 1539 2 1851
Examine the vertex IDs of the first neighbor, TN(1).
ans = 1093 891 893 858