Information concerning undocumented function “Region`Mesh`MeshNearestCellIndex[r ]”
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!
mesh meshfunction
add a comment |
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!
mesh meshfunction
Can you read theDownValues
? 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
4 hours ago
@b3m2a1 Nope,Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returnsRegion`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...
– Henrik Schumacher
4 hours ago
add a comment |
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!
mesh meshfunction
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!
mesh meshfunction
mesh meshfunction
edited 4 hours ago
Henrik Schumacher
48.8k467139
48.8k467139
asked 4 hours ago
Ulrich Neumann
7,250515
7,250515
Can you read theDownValues
? 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
4 hours ago
@b3m2a1 Nope,Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returnsRegion`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...
– Henrik Schumacher
4 hours ago
add a comment |
Can you read theDownValues
? 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
4 hours ago
@b3m2a1 Nope,Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returnsRegion`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...
– Henrik Schumacher
4 hours ago
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
4 hours ago
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
4 hours ago
@b3m2a1 Nope,
Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...– Henrik Schumacher
4 hours ago
@b3m2a1 Nope,
Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returns Region`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...– Henrik Schumacher
4 hours ago
add a comment |
1 Answer
1
active
oldest
votes
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];
cellfun[pi[[1]]]
{2, 2}
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
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];
cellfun[pi[[1]]]
{2, 2}
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
add a comment |
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];
cellfun[pi[[1]]]
{2, 2}
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
add a comment |
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];
cellfun[pi[[1]]]
{2, 2}
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];
cellfun[pi[[1]]]
{2, 2}
edited 4 hours ago
answered 4 hours ago
Henrik Schumacher
48.8k467139
48.8k467139
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
add a comment |
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
@ Henrik Thanks. Without the superfluous cells the ordering of the returned list seems to be arbitrary.
– Ulrich Neumann
4 hours ago
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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
4 hours ago
@b3m2a1 Nope,
Needs["GeneralUtilities`"]; PrintDefinitions[Region`Mesh`MeshNearestCellIndex]
returnsRegion`Mesh`MeshNearestCellIndex[___] := <<kernel function>>;
...– Henrik Schumacher
4 hours ago