How to generate a triangular grid from a list of pointsPoint 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

"Counterexample" for the Inverse function theorem

How to continually and organically let my readers know what time it is in my story?

What kind of environment would favor hermaphroditism in a sentient species over regular, old sexes?

SHAKE-128/256 or SHA3-256/512

Why is vowel phonology represented in a trapezoid instead of a square?

He is the first man to arrive here

Why aren't satellites disintegrated even though they orbit earth within their Roche Limits?

How can we delete item permanently without storing in Recycle Bin?

Cycling to work - 30mile return

Why does the U.S military use mercenaries?

How to generate a triangular grid from a list of points

Why didn't Daenerys' advisers suggest assassinating Cersei?

When the match time is called, does the current turn end immediately?

Failing students when it might cause them economic ruin

Usage of the relative pronoun "dont"

Why did nobody know who the Lord of this region was?

When did Britain learn about American independence?

Canadian citizen who is presently in litigation with a US-based company

Non-African Click Languages

Why would you put your input amplifier in front of your filtering for and ECG signal?

How to handle professionally if colleagues has referred his relative and asking to take easy while taking interview

Cannot remove door knob -- totally inaccessible!

What is the velocity distribution of the exhaust for a typical rocket engine?

Do high-wing aircraft represent more difficult engineering challenges than low-wing aircraft?



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













4












$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.










share|improve this question









New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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
    4 hours ago















4












$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.










share|improve this question









New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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
    4 hours ago













4












4








4





$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.










share|improve this question









New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






$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






share|improve this question









New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 7 hours ago









march

17.7k22870




17.7k22870






New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 7 hours ago









LilGregLilGreg

212




212




New contributor



LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




LilGreg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.













  • $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
    4 hours ago
















  • $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
    4 hours ago















$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
4 hours ago




$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
4 hours ago










3 Answers
3






active

oldest

votes


















3












$begingroup$

Try this:



R = DelaunayMesh[h[0, 0, 2]]


enter image description here



You may grab the edge indices with



MeshCells[R, 1]





share|improve this answer









$endgroup$




















    2












    $begingroup$

    You can use NearestNeighborGraph as follows:



    Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics


    enter image description here






    share|improve this answer









    $endgroup$




















      1












      $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]


      enter image description here






      share|improve this answer









      $endgroup$













        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.









        draft saved

        draft discarded


















        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

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        3












        $begingroup$

        Try this:



        R = DelaunayMesh[h[0, 0, 2]]


        enter image description here



        You may grab the edge indices with



        MeshCells[R, 1]





        share|improve this answer









        $endgroup$

















          3












          $begingroup$

          Try this:



          R = DelaunayMesh[h[0, 0, 2]]


          enter image description here



          You may grab the edge indices with



          MeshCells[R, 1]





          share|improve this answer









          $endgroup$















            3












            3








            3





            $begingroup$

            Try this:



            R = DelaunayMesh[h[0, 0, 2]]


            enter image description here



            You may grab the edge indices with



            MeshCells[R, 1]





            share|improve this answer









            $endgroup$



            Try this:



            R = DelaunayMesh[h[0, 0, 2]]


            enter image description here



            You may grab the edge indices with



            MeshCells[R, 1]






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered 7 hours ago









            Henrik SchumacherHenrik Schumacher

            62.2k586172




            62.2k586172





















                2












                $begingroup$

                You can use NearestNeighborGraph as follows:



                Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics


                enter image description here






                share|improve this answer









                $endgroup$

















                  2












                  $begingroup$

                  You can use NearestNeighborGraph as follows:



                  Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics


                  enter image description here






                  share|improve this answer









                  $endgroup$















                    2












                    2








                    2





                    $begingroup$

                    You can use NearestNeighborGraph as follows:



                    Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics


                    enter image description here






                    share|improve this answer









                    $endgroup$



                    You can use NearestNeighborGraph as follows:



                    Line[##] & @@@ EdgeList@NearestNeighborGraph[h[0, 0, 1]] // Graphics


                    enter image description here







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered 4 hours ago









                    marchmarch

                    17.7k22870




                    17.7k22870





















                        1












                        $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]


                        enter image description here






                        share|improve this answer









                        $endgroup$

















                          1












                          $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]


                          enter image description here






                          share|improve this answer









                          $endgroup$















                            1












                            1








                            1





                            $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]


                            enter image description here






                            share|improve this answer









                            $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]


                            enter image description here







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered 3 hours ago









                            MelaGoMelaGo

                            1,21317




                            1,21317




















                                LilGreg is a new contributor. Be nice, and check out our Code of Conduct.









                                draft saved

                                draft discarded


















                                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.




                                draft saved


                                draft discarded














                                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





















































                                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

                                Log på Navigationsmenu

                                Creating second map without labels using QGIS?How to lock map labels for inset map in Print Composer?How to Force the Showing of Labels of a Vector File in QGISQGIS Valmiera, Labels only show for part of polygonsRemoving duplicate point labels in QGISLabeling every feature using QGIS?Show labels for point features outside map canvasAbbreviate Road Labels in QGIS only when requiredExporting map from composer in QGIS - text labels have moved in output?How to make sure labels in qgis turn up in layout map?Writing label expression with ArcMap and If then Statement?

                                Nuuk Indholdsfortegnelse Etyomologi | Historie | Geografi | Transport og infrastruktur | Politik og administration | Uddannelsesinstitutioner | Kultur | Venskabsbyer | Noter | Eksterne henvisninger | Se også | Navigationsmenuwww.sermersooq.gl64°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.75064°10′N 51°45′V / 64.167°N 51.750°V / 64.167; -51.750DMI - KlimanormalerSalmonsen, s. 850Grønlands Naturinstitut undersøger rensdyr i Akia og Maniitsoq foråret 2008Grønlands NaturinstitutNy vej til Qinngorput indviet i dagAntallet af biler i Nuuk må begrænsesNy taxacentral mødt med demonstrationKøreplan. Rute 1, 2 og 3SnescootersporNuukNord er for storSkoler i Kommuneqarfik SermersooqAtuarfik Samuel KleinschmidtKangillinguit AtuarfiatNuussuup AtuarfiaNuuk Internationale FriskoleIlinniarfissuaq, Grønlands SeminariumLedelseÅrsberetning for 2008Kunst og arkitekturÅrsberetning for 2008Julie om naturenNuuk KunstmuseumSilamiutGrønlands Nationalmuseum og ArkivStatistisk ÅrbogGrønlands LandsbibliotekStore koncerter på stribeVandhund nummer 1.000.000Kommuneqarfik Sermersooq – MalikForsidenVenskabsbyerLyngby-Taarbæk i GrønlandArctic Business NetworkWinter Cities 2008 i NuukDagligt opdaterede satellitbilleder fra NuukområdetKommuneqarfik Sermersooqs hjemmesideTurist i NuukGrønlands Statistiks databankGrønlands Hjemmestyres valgresultaterrrWorldCat124325457671310-5