NearestMeshCells

NearestMeshCells[mr,pt]

gives the indices for the cells to which the point pt is nearest in the mesh region mr.

NearestMeshCells[mr,pt,n]

gives the n nearest cell indices to pt.

NearestMeshCells[mr,pt,{n,r}]

gives the n or fewer nearest cell indices to pt that are within radius r of pt.

NearestMeshCells[{mr,d},]

gives the indices for the cells of dimension d.

Details

  • NearestMeshCells is also known as nearest point or nearest region.
  • NearestMeshCells is typically used to find the closest cells in mesh from a given point.
  • The distance to a cell in a mesh is the distance to the closest point in that cell. The nearest cell is the one with the smallest distance.
  • NearestMeshCells returns a list of cell indexes of the form {d,{i1,i2,}}.

Examples

open allclose all

Basic Examples  (2)

Find the nearest line in the triangle:

Highlight the cell:

Find the nearest cell in the mesh region:

Highlight the cell:

Scope  (8)

Basic Uses  (2)

Find the cell nearest to {2,1}:

The point:

The line:

Find the 5 cells nearest to {1.5,.5}:

At most 10 cells within radius 0.5:

Mesh Regions  (2)

Find the nearest cell in a MeshRegion:

Highlight it:

Find the nearest line in a BoundaryMeshRegion:

Highlight it:

Polygons & Polyhedra  (4)

Applications  (1)

Find a Voronoi cell that corresponds the given point:

Highlight a Voronoi cell:

Interactive Examples  (1)

Nearest cells around the Voronoi mesh:

Neat Examples  (1)

Nearest cells around the space shuttle:

Introduced in 2020
 (12.1)