neighbors

Class: triangulation

Neighbors to specified triangle or tetrahedron

Syntax

`N = neighbors(TR,ti)N = neighbors(TR)`

Description

`N = neighbors(TR,ti)` returns the neighbors of the triangles or tetrahedra specified in `ti`.

`N = neighbors(TR)` returns the neighbors of all the triangles or tetrahedra.

Input Arguments

 `TR` Triangulation representation, see `triangulation` or `delaunayTriangulation`. `ti` Triangle or tetrahedron IDs, specified as a column vector.

Output Arguments

 `TN` 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 `j`th 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`.

Definitions

Triangle or Tetrahedron ID

A row number of the matrix, `TR.ConnectivityList`. Use this ID to refer a specific triangle or tetrahedron.

Vertex ID

A row number of the matrix, `TR.Points`. Use this ID to refer a specific vertex in the triangulation.

Examples

collapse all

Query Neighbors in 2-D Delaunay 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)`.

`DT.ConnectivityList(TN(2),:)`
```ans = 2 4 7```

Query Neighbors in 3-D Triangulation

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.

`TN(5,:)`
```ans = 2360 1539 2 1851```

Examine the vertex IDs of the first neighbor, `TN(1)`.

`TR.ConnectivityList(TN(1),:)`
```ans = 1093 891 893 858```