I'm looking for further information of the undocumented function Region`Mesh`MeshNearestCellIndex[r]
(Thanks to Henrik Schumacher!)
The function considers a meshregion r
and detects the nearest cell to a given point. Trying to understand I look at a very simple triangle mesh in space:
pi={{0., 0., 0.303}, {1., -0.5, 0.09}, {0.7, 0.8, -0.233}, {0.,1., -0.584}, {-0.8, -0.7, -0.734}}
Δi = {{1, 2, 3}, {1, 3, 4}, {1, 4, 5}, {1, 5, 2}};
r = MeshRegion[pi , Triangle[Δi]];
HighlightMesh[r, {Labeled[0, "Index"], Labeled[2, "Index"]}]
Now I want to evaluate the nearest cells of point 1
Region`Mesh`MeshNearestCellIndex[r , pi[[1]] ]
(*{2, 1}*)
Expecting four possible cells as nearest neighbors MMA returns element #1.
My question: How does MMA evaluate the priority of the possible cells? Thanks!
DownValues
? That’s the place to start if they’re available. If not we’re at the mercy of WRI developers or wherever one can find the function used in the source code. $\endgroup$Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returnsRegion`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
... $\endgroup$