How to generate a triangular grid from a list of points?Point lattice leading to triangle latticeCombining 3 graphics of different coordinate systemsCreate triangular mesh from random list of pointsInterpolation on a regular square grid spanning a triangular domainHow to generate grid points on boundary of $[-1,1]^d$ for arbitrary dimension $d$ and specified resolution?How to generate the rows of data points from a model?How to apply $overliner(x,y)$ to shapes with straight lines or absolute values?How to make a cow smaller (in BubbleChart3D plot)How to plot a 2D triangular latticeHow to generate animation from manipulate?Point lattice leading to triangle lattice
Papers on ArXiv as main references
Can I render satellite deployment impossible, or at least impractical, by exploiting the Kessler syndrome?
Where is Jon going?
Is keeping the forking link on a true fork necessary (Github/GPL)?
Team has team lunch everyday, am I forced to go?
How to teach an undergraduate course without having taken that course formally before?
Is there an idiom that means that you are in a very strong negotiation position in a negotiation?
How to deceive the MC
Split into three!
Are cells guaranteed to get at least one mitochondrion when they divide?
Does water in vacuum form a solid shell or freeze solid?
Are there any German nonsense poems (Jabberwocky)?
ifconfig shows UP while ip link shows DOWN
Reduce size of sum sub/superscript?
The disk image is 497GB smaller than the target device
"Official wife" or "Formal wife"?
How does Dreadhorde Arcanist interact with split cards?
Time complexity of an algorithm: Is it important to state the base of the logarithm?
Why A=2 and B=1 in the call signs for Spirit and Opportunity?
Did Game of Thrones end the way that George RR Martin intended?
How does the Earth's center produce heat?
How can I get a refund from a seller who only accepts Zelle?
Goldfish unresponsive, what should I do?
Flatten not working
How to generate a triangular grid from a list of points?
Point lattice leading to triangle latticeCombining 3 graphics of different coordinate systemsCreate triangular mesh from random list of pointsInterpolation on a regular square grid spanning a triangular domainHow to generate grid points on boundary of $[-1,1]^d$ for arbitrary dimension $d$ and specified resolution?How to generate the rows of data points from a model?How to apply $overliner(x,y)$ to shapes with straight lines or absolute values?How to make a cow smaller (in BubbleChart3D plot)How to plot a 2D triangular latticeHow to generate animation from manipulate?Point lattice leading to triangle lattice
$begingroup$
I am newbie with mathematica and the other day I saw a function that generates points from an original one defined as:
h[x_, y_, 0] := Prepend[Table[Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y, k,6], 0, 0]
h[x_, y_, n_] :=DeleteDuplicates[Flatten[Table[Cos[2 Pi k/6] + #1, Sin[2 Pi k/6] + #2, k, 6] & @@@h[x, y, n - 1], 1]]
So I started from this function and tried to create a triangle lattice with a new function definied as:
L[x_, y_, n_] :=Show@Graphics@While[j < Length[h[x, y, n] + 1],
For[i = 1, i < Length[h[x, y, n] + 1] , i++ ,
If[EuclideanDistance[h[x, y, n][[j]], h[x, y, n][[i]]] == 1,
Line[h[x, y, n][[j]], h[x, y, n][[i]]],
Point[h[x, y, n][[j]], h[x, y, n][[i]]]]]; j++]
But it doesn't work... I wanted to connect all the dots that were seperated by a distance of 1 and plot a graphic with them. It seems that i am not using for as it should properly be.
graphics lattices
New contributor
$endgroup$
add a comment |
$begingroup$
I am newbie with mathematica and the other day I saw a function that generates points from an original one defined as:
h[x_, y_, 0] := Prepend[Table[Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y, k,6], 0, 0]
h[x_, y_, n_] :=DeleteDuplicates[Flatten[Table[Cos[2 Pi k/6] + #1, Sin[2 Pi k/6] + #2, k, 6] & @@@h[x, y, n - 1], 1]]
So I started from this function and tried to create a triangle lattice with a new function definied as:
L[x_, y_, n_] :=Show@Graphics@While[j < Length[h[x, y, n] + 1],
For[i = 1, i < Length[h[x, y, n] + 1] , i++ ,
If[EuclideanDistance[h[x, y, n][[j]], h[x, y, n][[i]]] == 1,
Line[h[x, y, n][[j]], h[x, y, n][[i]]],
Point[h[x, y, n][[j]], h[x, y, n][[i]]]]]; j++]
But it doesn't work... I wanted to connect all the dots that were seperated by a distance of 1 and plot a graphic with them. It seems that i am not using for as it should properly be.
graphics lattices
New contributor
$endgroup$
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33
add a comment |
$begingroup$
I am newbie with mathematica and the other day I saw a function that generates points from an original one defined as:
h[x_, y_, 0] := Prepend[Table[Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y, k,6], 0, 0]
h[x_, y_, n_] :=DeleteDuplicates[Flatten[Table[Cos[2 Pi k/6] + #1, Sin[2 Pi k/6] + #2, k, 6] & @@@h[x, y, n - 1], 1]]
So I started from this function and tried to create a triangle lattice with a new function definied as:
L[x_, y_, n_] :=Show@Graphics@While[j < Length[h[x, y, n] + 1],
For[i = 1, i < Length[h[x, y, n] + 1] , i++ ,
If[EuclideanDistance[h[x, y, n][[j]], h[x, y, n][[i]]] == 1,
Line[h[x, y, n][[j]], h[x, y, n][[i]]],
Point[h[x, y, n][[j]], h[x, y, n][[i]]]]]; j++]
But it doesn't work... I wanted to connect all the dots that were seperated by a distance of 1 and plot a graphic with them. It seems that i am not using for as it should properly be.
graphics lattices
New contributor
$endgroup$
I am newbie with mathematica and the other day I saw a function that generates points from an original one defined as:
h[x_, y_, 0] := Prepend[Table[Cos[2 Pi k/6] + x, Sin[2 Pi k/6] + y, k,6], 0, 0]
h[x_, y_, n_] :=DeleteDuplicates[Flatten[Table[Cos[2 Pi k/6] + #1, Sin[2 Pi k/6] + #2, k, 6] & @@@h[x, y, n - 1], 1]]
So I started from this function and tried to create a triangle lattice with a new function definied as:
L[x_, y_, n_] :=Show@Graphics@While[j < Length[h[x, y, n] + 1],
For[i = 1, i < Length[h[x, y, n] + 1] , i++ ,
If[EuclideanDistance[h[x, y, n][[j]], h[x, y, n][[i]]] == 1,
Line[h[x, y, n][[j]], h[x, y, n][[i]]],
Point[h[x, y, n][[j]], h[x, y, n][[i]]]]]; j++]
But it doesn't work... I wanted to connect all the dots that were seperated by a distance of 1 and plot a graphic with them. It seems that i am not using for as it should properly be.
graphics lattices
graphics lattices
New contributor
New contributor
edited May 16 at 6:38
user64494
3,74711222
3,74711222
New contributor
asked May 15 at 19:58
LilGregLilGreg
362
362
New contributor
New contributor
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33
add a comment |
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33
add a comment |
4 Answers
4
active
oldest
votes
$begingroup$
Try this:
R = DelaunayMesh[h[0, 0, 2]]
You may grab the edge indices with
MeshCells[R, 1]
$endgroup$
add a comment |
$begingroup$
You can use NearestNeighborGraph
as follows:
Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics
$endgroup$
add a comment |
$begingroup$
Your code wasn't far off, though the other answers may be more elegant.
This works:
L2[x_, y_, n_] := Module[pts,
pts = h[x, y, n];
Show[Graphics[
Point[pts],
Table[
If[EuclideanDistance[pts[[i]], pts[[j]]] == 1,
Line[pts[[i]], pts[[j]]]], i, Length[pts], j, Length[pts]]
]]]
L2[0, 0, 2]
$endgroup$
add a comment |
$begingroup$
Another way to use NearestNeighborGraph
:
NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
Alternatively, you can use RelationGraph
:
RelationGraph[.1 < EuclideanDistance@## <= 1 &, h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
same picture
To remove the vertices and to get a Graphics
object you can use:
Show @ NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1],
VertexShapeFunction -> None]
$endgroup$
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
add a comment |
Your Answer
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
);
);
LilGreg is a new contributor. Be nice, and check out our Code of Conduct.
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%2f198425%2fhow-to-generate-a-triangular-grid-from-a-list-of-points%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
4 Answers
4
active
oldest
votes
4 Answers
4
active
oldest
votes
active
oldest
votes
active
oldest
votes
$begingroup$
Try this:
R = DelaunayMesh[h[0, 0, 2]]
You may grab the edge indices with
MeshCells[R, 1]
$endgroup$
add a comment |
$begingroup$
Try this:
R = DelaunayMesh[h[0, 0, 2]]
You may grab the edge indices with
MeshCells[R, 1]
$endgroup$
add a comment |
$begingroup$
Try this:
R = DelaunayMesh[h[0, 0, 2]]
You may grab the edge indices with
MeshCells[R, 1]
$endgroup$
Try this:
R = DelaunayMesh[h[0, 0, 2]]
You may grab the edge indices with
MeshCells[R, 1]
answered May 15 at 20:02
Henrik SchumacherHenrik Schumacher
62.9k587176
62.9k587176
add a comment |
add a comment |
$begingroup$
You can use NearestNeighborGraph
as follows:
Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics
$endgroup$
add a comment |
$begingroup$
You can use NearestNeighborGraph
as follows:
Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics
$endgroup$
add a comment |
$begingroup$
You can use NearestNeighborGraph
as follows:
Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics
$endgroup$
You can use NearestNeighborGraph
as follows:
Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics
answered May 15 at 23:19
marchmarch
17.8k22870
17.8k22870
add a comment |
add a comment |
$begingroup$
Your code wasn't far off, though the other answers may be more elegant.
This works:
L2[x_, y_, n_] := Module[pts,
pts = h[x, y, n];
Show[Graphics[
Point[pts],
Table[
If[EuclideanDistance[pts[[i]], pts[[j]]] == 1,
Line[pts[[i]], pts[[j]]]], i, Length[pts], j, Length[pts]]
]]]
L2[0, 0, 2]
$endgroup$
add a comment |
$begingroup$
Your code wasn't far off, though the other answers may be more elegant.
This works:
L2[x_, y_, n_] := Module[pts,
pts = h[x, y, n];
Show[Graphics[
Point[pts],
Table[
If[EuclideanDistance[pts[[i]], pts[[j]]] == 1,
Line[pts[[i]], pts[[j]]]], i, Length[pts], j, Length[pts]]
]]]
L2[0, 0, 2]
$endgroup$
add a comment |
$begingroup$
Your code wasn't far off, though the other answers may be more elegant.
This works:
L2[x_, y_, n_] := Module[pts,
pts = h[x, y, n];
Show[Graphics[
Point[pts],
Table[
If[EuclideanDistance[pts[[i]], pts[[j]]] == 1,
Line[pts[[i]], pts[[j]]]], i, Length[pts], j, Length[pts]]
]]]
L2[0, 0, 2]
$endgroup$
Your code wasn't far off, though the other answers may be more elegant.
This works:
L2[x_, y_, n_] := Module[pts,
pts = h[x, y, n];
Show[Graphics[
Point[pts],
Table[
If[EuclideanDistance[pts[[i]], pts[[j]]] == 1,
Line[pts[[i]], pts[[j]]]], i, Length[pts], j, Length[pts]]
]]]
L2[0, 0, 2]
answered May 16 at 0:47
MelaGoMelaGo
1,37017
1,37017
add a comment |
add a comment |
$begingroup$
Another way to use NearestNeighborGraph
:
NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
Alternatively, you can use RelationGraph
:
RelationGraph[.1 < EuclideanDistance@## <= 1 &, h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
same picture
To remove the vertices and to get a Graphics
object you can use:
Show @ NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1],
VertexShapeFunction -> None]
$endgroup$
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
add a comment |
$begingroup$
Another way to use NearestNeighborGraph
:
NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
Alternatively, you can use RelationGraph
:
RelationGraph[.1 < EuclideanDistance@## <= 1 &, h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
same picture
To remove the vertices and to get a Graphics
object you can use:
Show @ NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1],
VertexShapeFunction -> None]
$endgroup$
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
add a comment |
$begingroup$
Another way to use NearestNeighborGraph
:
NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
Alternatively, you can use RelationGraph
:
RelationGraph[.1 < EuclideanDistance@## <= 1 &, h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
same picture
To remove the vertices and to get a Graphics
object you can use:
Show @ NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1],
VertexShapeFunction -> None]
$endgroup$
Another way to use NearestNeighborGraph
:
NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
Alternatively, you can use RelationGraph
:
RelationGraph[.1 < EuclideanDistance@## <= 1 &, h[0, 0, 1], VertexCoordinates -> h[0, 0, 1]]
same picture
To remove the vertices and to get a Graphics
object you can use:
Show @ NearestNeighborGraph[h[0, 0, 1], VertexCoordinates -> h[0, 0, 1],
VertexShapeFunction -> None]
edited May 16 at 7:14
answered May 16 at 7:08
kglrkglr
193k10214435
193k10214435
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
add a comment |
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
$begingroup$
Thank you for your help! I didn't know there was a function, I appreciate your help.
$endgroup$
– LilGreg
May 16 at 17:48
add a comment |
LilGreg is a new contributor. Be nice, and check out our Code of Conduct.
LilGreg is a new contributor. Be nice, and check out our Code of Conduct.
LilGreg is a new contributor. Be nice, and check out our Code of Conduct.
LilGreg is a new contributor. Be nice, and check out our Code of Conduct.
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.
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%2f198425%2fhow-to-generate-a-triangular-grid-from-a-list-of-points%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
$begingroup$
I've edited your question to include a link to what you saw the other day. In the future, make sure to do this so that you can give questions and answerers their proper credit! In addition, once you have enough rep (which I think you do), make sure to upvote questions and/or answers that you found useful (which includes the now-linked ones, I assume, since you asked a question about it!).
$endgroup$
– march
May 15 at 23:33