# 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:

## Applications(1)

Find a Voronoi cell that corresponds to 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:

Wolfram Research (2020), NearestMeshCells, Wolfram Language function, https://reference.wolfram.com/language/ref/NearestMeshCells.html.

#### Text

Wolfram Research (2020), NearestMeshCells, Wolfram Language function, https://reference.wolfram.com/language/ref/NearestMeshCells.html.

#### CMS

Wolfram Language. 2020. "NearestMeshCells." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NearestMeshCells.html.

#### APA

Wolfram Language. (2020). NearestMeshCells. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NearestMeshCells.html

#### BibTeX

@misc{reference.wolfram_2024_nearestmeshcells, author="Wolfram Research", title="{NearestMeshCells}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NearestMeshCells.html}", note=[Accessed: 02-August-2024 ]}

#### BibLaTeX

@online{reference.wolfram_2024_nearestmeshcells, organization={Wolfram Research}, title={NearestMeshCells}, year={2020}, url={https://reference.wolfram.com/language/ref/NearestMeshCells.html}, note=[Accessed: 02-August-2024 ]}