RegionNearest

RegionNearest[reg,p]

gives a point in the region reg that is nearest the point p.

RegionNearest[reg]

gives a RegionNearestFunction[] that can be repeatedly applied to points.

Details

Examples

open allclose all

Basic Examples  (2)

Find the nearest point in the unit disk:

Plot it:

Find the nearest point in a MeshRegion:

With one argument you get a RegionNearestFunction:

Apply the function to lists of points to compute many nearest points:

Scope  (16)

Special Regions  (7)

Point sets:

They work in any dimension:

Visualize the nearest points:

Line:

Visualize it:

Rectangle can be used in 2D:

Cuboid generalizes it to any dimension:

Visualize the nearest points on a rectangle:

Simplex:

Visualize the nearest points on a 2D simplex:

Polygon:

Visualize the nearest points in a hexagon:

Disk can be used in 2D:

Ball generalizes a disk in any dimension:

Visualize the nearest points on a 3D ball:

Disk can be an ellipse in 2D:

Ellipsoid generalizes ellipses to any dimension:

Plot the nearest points on an ellipse:

Formula Regions  (2)

The nearest point on a disk represented as an ImplicitRegion:

A cylinder:

The nearest point on a disk represented as a ParametricRegion:

Using a rational parametrization of the disk:

A cylinder:

Mesh Regions  (4)

The nearest point in a 1D BoundaryMeshRegion:

2D:

3D:

The nearest point in a 0D MeshRegion in 1D:

A 1D region:

The nearest point in a 0D MeshRegion in 2D:

A 1D region:

A 2D region:

The nearest point in a 0D MeshRegion in 3D:

A 1D region:

A 2D region:

A 3D region:

Derived Regions  (3)

The distance to a RegionIntersection:

The distance to a TransformedRegion:

The distance to a RegionBoundary:

Applications  (3)

Visualize the nearest points in a region:

The nearest points along two circles:

Visualize a region by mapping uniform points to the region using RegionNearest:

Find the altitude of a triangle:

Visualize altitude in red:

Properties & Relations  (4)

Only one point is returned in case there is a tie:

Visualize the nearest point chosen in red:

A point is a RegionMember if the nearest point to the region is itself:

RegionNearest is closely related to RegionDistance:

The distance to the nearest point is minimal:

Nearest gives nearest points for finite point regions:

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

Text

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

CMS

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

APA

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

BibTeX

@misc{reference.wolfram_2024_regionnearest, author="Wolfram Research", title="{RegionNearest}", year="2014", howpublished="\url{https://reference.wolfram.com/language/ref/RegionNearest.html}", note=[Accessed: 05-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_regionnearest, organization={Wolfram Research}, title={RegionNearest}, year={2014}, url={https://reference.wolfram.com/language/ref/RegionNearest.html}, note=[Accessed: 05-November-2024 ]}