In this previous question we see that RegionNearest
isn't quite as 'capable' as Nearest
for some things.
Similarly, I need to be able to find a given neighborhood of points on a MeshRegion
. With just a set of vertices, one can easily use Nearest
with the form Nearest[p,{nDesired,radius}]
. Unfortunately, this does not work with MeshRegion
, RegionNearestFunction
, and friends. For example-
r = BoundaryDiscretizeRegion[Ball[]];
v = MeshCoordinates[r];
p = v[[1]];
f = RegionNearest[r];
f[p]
(* {-0.156227, 0.987698, 0.00678839} *)
f[p, {10, 0.1}]
(* RegionNearestFunction::argx: RegionNearestFunction [...] called with 2 arguments; 1 argument is expected *)
Obviously, I can use Nearest[]
on the mesh coordinates and get an answer -
ff = Nearest[v];
ff[p, {10, 0.5}]
(* {{-0.156227, 0.987698, 0.00678839}, {-0.232192, ... *)
But this doesn't take advantage of the graph-connectivity in the MeshRegion data structure. The meshes that I deal with are much more complicated than a simple sphere here, so the Norm[p-q]
method it uses in this case gives bad values when there are 'creases' or 'folds' in the surface.
It would seem that getting the n-Ring neighbors of a point p on a MeshRegion should be a pretty straight forward thing (I have plenty of code that does this for GraphicsComplex
style data) and maybe even something that should be built in, but I can't quite figure out how to do it (or traverse a MeshRegion
as if it were a Graph
for what that's worth.) Does anyone have a suggestion for how to take advantage of the new ...Region
features for this sort of thing?
(n.b.- more specifically, I need this information to compute the differential geometry at all discrete v in r or, even better, an interpolation for any point in r. I've been playing with some of the new Computational Geometry features but can't quite figure out how to do this on MeshRegions. I again have some code that turns meshes into nonuniform-interpolated functions that I can play with this way, but, again, would like to find a way to do, say, ArcCurvature
, FrenetSetretSystem
sort of things on surfaces instead of just lines. See this mercifully closed question of mine for related angst.)