Triangle or tetrahedron neighbors
returns the IDs of the neighbors to all triangles or tetrahedra in
N = neighbors(
N is a 3-column (2-D) or 4-column
(3-D) matrix whose rows contain the IDs of the neighboring triangles or tetrahedra
to that element in the triangulation.
Find neighboring tetrahedra in a 3-D triangulation.
Create a 3-D triangulation.
load tetmesh TR = triangulation(tet,X);
Compute the IDs of the neighboring tetrahedra to each element of the triangulation.
N = neighbors(TR);
Display the IDs of the neighbors to the fifth tetrahedron.
ans = 1×4 2360 1539 2 1851
Examine the vertex IDs of the first neighbor.
ans = 1×4 1093 891 893 858
2-D Delaunay Triangulation
Find neighboring triangles in a 2-D Delaunay triangulation.
Create a 2-D Delaunay triangulation.
rng('default') x = rand([10,1]); y = rand([10,1]); TR = delaunayTriangulation(x,y);
Find the neighbors of the first triangle.
NaN indicates that the triangle is on the boundary of the triangulation and only has two neighbors.
N = neighbors(TR,1)
N = 1×3 4 8 5
Examine the vertex IDs of the third neighbor.
ans = 1×3 3 8 2
ID — Triangle or tetrahedron IDs
scalar | column vector
Triangle or tetrahedron IDs, specified as a scalar or a column vector
whose elements correspond to a single triangle or tetrahedron in the
triangulation object. The ID of each triangle or tetrahedron is the
corresponding row number of the
If a triangle or tetrahedron has one or more boundary facets, the
nonexistent neighbors are represented as
NaN values in
Run code in the background using MATLAB®
backgroundPool or accelerate code with Parallel Computing Toolbox™
This function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Introduced in R2013a