Information concerning undocumented function “Region`Mesh`MeshNearestCellIndex[r ]”












2














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"]}]


enter image description here



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!










share|improve this question
























  • Can you read the 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.
    – b3m2a1
    Jan 1 at 22:37










  • @b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
    – Henrik Schumacher
    Jan 1 at 22:40


















2














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"]}]


enter image description here



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!










share|improve this question
























  • Can you read the 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.
    – b3m2a1
    Jan 1 at 22:37










  • @b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
    – Henrik Schumacher
    Jan 1 at 22:40
















2












2








2







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"]}]


enter image description here



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!










share|improve this question















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"]}]


enter image description here



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!







mesh meshfunction






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 1 at 22:39









Henrik Schumacher

49.8k469143




49.8k469143










asked Jan 1 at 22:24









Ulrich NeumannUlrich Neumann

7,725516




7,725516












  • Can you read the 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.
    – b3m2a1
    Jan 1 at 22:37










  • @b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
    – Henrik Schumacher
    Jan 1 at 22:40




















  • Can you read the 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.
    – b3m2a1
    Jan 1 at 22:37










  • @b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
    – Henrik Schumacher
    Jan 1 at 22:40


















Can you read the 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.
– b3m2a1
Jan 1 at 22:37




Can you read the 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.
– b3m2a1
Jan 1 at 22:37












@b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
– Henrik Schumacher
Jan 1 at 22:40






@b3m2a1 Nope, Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex] returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;...
– Henrik Schumacher
Jan 1 at 22:40












1 Answer
1






active

oldest

votes


















3














If I had to make a guess, I'd say Mathematica breaks ties by choosing the cell with the smallest index:



Δi = {{1, 3, 4}, {1, 2, 3}, {1, 4, 5}, {1, 5, 2}};
Table[
r = MeshRegion[pi, Triangle[Δi[[perm]]]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]]],
{perm, PermutationList /@ Permutations[Range[4]]}
]



{{2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}}




By the way, I just found out that you can also obtain the $n$ nearest cells as follows:



r = MeshRegion[pi, Triangle[Δi]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]], 10]



{{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}}




Apparently, superfluous cells obtain the index 0...



Oh, an apparently, there is also an operator version of the Region`Mesh`MeshNearestCellIndex, similarly as for Nearest:



cellfun = Region`Mesh`MeshNearestCellIndex[r];


enter image description here



cellfun[pi[[1]]]



{2, 2}







share|improve this answer























  • @ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
    – Ulrich Neumann
    Jan 1 at 22:54













Your Answer





StackExchange.ifUsing("editor", function () {
return StackExchange.using("mathjaxEditing", function () {
StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
});
});
}, "mathjax-editing");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "387"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188686%2finformation-concerning-undocumented-function-regionmeshmeshnearestcellindexr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














If I had to make a guess, I'd say Mathematica breaks ties by choosing the cell with the smallest index:



Δi = {{1, 3, 4}, {1, 2, 3}, {1, 4, 5}, {1, 5, 2}};
Table[
r = MeshRegion[pi, Triangle[Δi[[perm]]]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]]],
{perm, PermutationList /@ Permutations[Range[4]]}
]



{{2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}}




By the way, I just found out that you can also obtain the $n$ nearest cells as follows:



r = MeshRegion[pi, Triangle[Δi]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]], 10]



{{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}}




Apparently, superfluous cells obtain the index 0...



Oh, an apparently, there is also an operator version of the Region`Mesh`MeshNearestCellIndex, similarly as for Nearest:



cellfun = Region`Mesh`MeshNearestCellIndex[r];


enter image description here



cellfun[pi[[1]]]



{2, 2}







share|improve this answer























  • @ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
    – Ulrich Neumann
    Jan 1 at 22:54


















3














If I had to make a guess, I'd say Mathematica breaks ties by choosing the cell with the smallest index:



Δi = {{1, 3, 4}, {1, 2, 3}, {1, 4, 5}, {1, 5, 2}};
Table[
r = MeshRegion[pi, Triangle[Δi[[perm]]]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]]],
{perm, PermutationList /@ Permutations[Range[4]]}
]



{{2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}}




By the way, I just found out that you can also obtain the $n$ nearest cells as follows:



r = MeshRegion[pi, Triangle[Δi]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]], 10]



{{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}}




Apparently, superfluous cells obtain the index 0...



Oh, an apparently, there is also an operator version of the Region`Mesh`MeshNearestCellIndex, similarly as for Nearest:



cellfun = Region`Mesh`MeshNearestCellIndex[r];


enter image description here



cellfun[pi[[1]]]



{2, 2}







share|improve this answer























  • @ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
    – Ulrich Neumann
    Jan 1 at 22:54
















3












3








3






If I had to make a guess, I'd say Mathematica breaks ties by choosing the cell with the smallest index:



Δi = {{1, 3, 4}, {1, 2, 3}, {1, 4, 5}, {1, 5, 2}};
Table[
r = MeshRegion[pi, Triangle[Δi[[perm]]]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]]],
{perm, PermutationList /@ Permutations[Range[4]]}
]



{{2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}}




By the way, I just found out that you can also obtain the $n$ nearest cells as follows:



r = MeshRegion[pi, Triangle[Δi]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]], 10]



{{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}}




Apparently, superfluous cells obtain the index 0...



Oh, an apparently, there is also an operator version of the Region`Mesh`MeshNearestCellIndex, similarly as for Nearest:



cellfun = Region`Mesh`MeshNearestCellIndex[r];


enter image description here



cellfun[pi[[1]]]



{2, 2}







share|improve this answer














If I had to make a guess, I'd say Mathematica breaks ties by choosing the cell with the smallest index:



Δi = {{1, 3, 4}, {1, 2, 3}, {1, 4, 5}, {1, 5, 2}};
Table[
r = MeshRegion[pi, Triangle[Δi[[perm]]]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]]],
{perm, PermutationList /@ Permutations[Range[4]]}
]



{{2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}, {2, 1}}




By the way, I just found out that you can also obtain the $n$ nearest cells as follows:



r = MeshRegion[pi, Triangle[Δi]];
Region`Mesh`MeshNearestCellIndex[r, pi[[1]], 10]



{{2, 1}, {2, 2}, {2, 3}, {2, 4}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}, {2, 0}}




Apparently, superfluous cells obtain the index 0...



Oh, an apparently, there is also an operator version of the Region`Mesh`MeshNearestCellIndex, similarly as for Nearest:



cellfun = Region`Mesh`MeshNearestCellIndex[r];


enter image description here



cellfun[pi[[1]]]



{2, 2}








share|improve this answer














share|improve this answer



share|improve this answer








edited Jan 1 at 22:47

























answered Jan 1 at 22:38









Henrik SchumacherHenrik Schumacher

49.8k469143




49.8k469143












  • @ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
    – Ulrich Neumann
    Jan 1 at 22:54




















  • @ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
    – Ulrich Neumann
    Jan 1 at 22:54


















@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
Jan 1 at 22:54






@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
Jan 1 at 22:54




















draft saved

draft discarded




















































Thanks for contributing an answer to Mathematica Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


Use MathJax to format equations. MathJax reference.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f188686%2finformation-concerning-undocumented-function-regionmeshmeshnearestcellindexr%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

How to change which sound is reproduced for terminal bell?

Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

Can I use Tabulator js library in my java Spring + Thymeleaf project?