Drawing many random paths in TikZ

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite












I'm trying to draw a diagram in TikZ that helps visually explain an analogy I'm trying to make in a paper. Basically, I want to start with a plane that contains many random paths of different lengths, such as that below. I created that diagram by compiling the code below in LuaLaTeX, which combines two other answers on the site (at Drawing random paths and Drawing in random locations -- you will need to use the poisson disc sampling library the latter refers to).



I want to make a few tweaks to the output. Firstly, to tidy it up, I don't want the paths to be able to turn back on themselves so easily, so as to eliminate the sharp kinks and arrowheads pointing the 'wrong' direction in some of the paths. Secondly, if possible, I want some of the paths to be loosely correlated to one another: as if certain paths had a mass that gravitationally attracted the paths around them to some degree. And I want these certain paths to be drawn in a different colour to all the other paths.



Is this possible? I'd be very grateful for any help.



A plane containing many random paths of different lengths



RequirePackageluatex85
documentclassstandalone
usepackagetikz
usepackagepoisson
begindocument
edefmylistpoissonpointslist1050.3320

begintikzpicture

foreach x/y in mylist
draw[->, rounded corners=5pt] (x,y)
foreach i in 1,...,3
-- ++(rnd*180:rnd)
;


endtikzpicture
enddocument









share|improve this question

























    up vote
    2
    down vote

    favorite












    I'm trying to draw a diagram in TikZ that helps visually explain an analogy I'm trying to make in a paper. Basically, I want to start with a plane that contains many random paths of different lengths, such as that below. I created that diagram by compiling the code below in LuaLaTeX, which combines two other answers on the site (at Drawing random paths and Drawing in random locations -- you will need to use the poisson disc sampling library the latter refers to).



    I want to make a few tweaks to the output. Firstly, to tidy it up, I don't want the paths to be able to turn back on themselves so easily, so as to eliminate the sharp kinks and arrowheads pointing the 'wrong' direction in some of the paths. Secondly, if possible, I want some of the paths to be loosely correlated to one another: as if certain paths had a mass that gravitationally attracted the paths around them to some degree. And I want these certain paths to be drawn in a different colour to all the other paths.



    Is this possible? I'd be very grateful for any help.



    A plane containing many random paths of different lengths



    RequirePackageluatex85
    documentclassstandalone
    usepackagetikz
    usepackagepoisson
    begindocument
    edefmylistpoissonpointslist1050.3320

    begintikzpicture

    foreach x/y in mylist
    draw[->, rounded corners=5pt] (x,y)
    foreach i in 1,...,3
    -- ++(rnd*180:rnd)
    ;


    endtikzpicture
    enddocument









    share|improve this question























      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite











      I'm trying to draw a diagram in TikZ that helps visually explain an analogy I'm trying to make in a paper. Basically, I want to start with a plane that contains many random paths of different lengths, such as that below. I created that diagram by compiling the code below in LuaLaTeX, which combines two other answers on the site (at Drawing random paths and Drawing in random locations -- you will need to use the poisson disc sampling library the latter refers to).



      I want to make a few tweaks to the output. Firstly, to tidy it up, I don't want the paths to be able to turn back on themselves so easily, so as to eliminate the sharp kinks and arrowheads pointing the 'wrong' direction in some of the paths. Secondly, if possible, I want some of the paths to be loosely correlated to one another: as if certain paths had a mass that gravitationally attracted the paths around them to some degree. And I want these certain paths to be drawn in a different colour to all the other paths.



      Is this possible? I'd be very grateful for any help.



      A plane containing many random paths of different lengths



      RequirePackageluatex85
      documentclassstandalone
      usepackagetikz
      usepackagepoisson
      begindocument
      edefmylistpoissonpointslist1050.3320

      begintikzpicture

      foreach x/y in mylist
      draw[->, rounded corners=5pt] (x,y)
      foreach i in 1,...,3
      -- ++(rnd*180:rnd)
      ;


      endtikzpicture
      enddocument









      share|improve this question













      I'm trying to draw a diagram in TikZ that helps visually explain an analogy I'm trying to make in a paper. Basically, I want to start with a plane that contains many random paths of different lengths, such as that below. I created that diagram by compiling the code below in LuaLaTeX, which combines two other answers on the site (at Drawing random paths and Drawing in random locations -- you will need to use the poisson disc sampling library the latter refers to).



      I want to make a few tweaks to the output. Firstly, to tidy it up, I don't want the paths to be able to turn back on themselves so easily, so as to eliminate the sharp kinks and arrowheads pointing the 'wrong' direction in some of the paths. Secondly, if possible, I want some of the paths to be loosely correlated to one another: as if certain paths had a mass that gravitationally attracted the paths around them to some degree. And I want these certain paths to be drawn in a different colour to all the other paths.



      Is this possible? I'd be very grateful for any help.



      A plane containing many random paths of different lengths



      RequirePackageluatex85
      documentclassstandalone
      usepackagetikz
      usepackagepoisson
      begindocument
      edefmylistpoissonpointslist1050.3320

      begintikzpicture

      foreach x/y in mylist
      draw[->, rounded corners=5pt] (x,y)
      foreach i in 1,...,3
      -- ++(rnd*180:rnd)
      ;


      endtikzpicture
      enddocument






      tikz-pgf luatex diagrams random randomwalk






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 59 mins ago









      solisoc

      615




      615




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          3
          down vote













          Something like this?



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture

          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*360
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=5pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here



          I first compute a main angle and then add fluctuations to it which are between -60 and +60. To make the objects cluster, I add a function that will move things that are close to the clustering point a bit closer to it, and things that are remote even a bit further away.



          Here is another proposal in which the directions are correlated, and the sharp corners are gone. They appear above because some segments are super short.



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture
          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*60+(x+y)*120
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=10pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:0.2+0.8*rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
            – solisoc
            22 mins ago










          • @solisoc I added another option.
            – marmot
            12 mins ago










          • This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
            – solisoc
            4 mins ago










          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "85"
          ;
          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',
          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%2ftex.stackexchange.com%2fquestions%2f458593%2fdrawing-many-random-paths-in-tikz%23new-answer', 'question_page');

          );

          Post as a guest






























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          3
          down vote













          Something like this?



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture

          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*360
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=5pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here



          I first compute a main angle and then add fluctuations to it which are between -60 and +60. To make the objects cluster, I add a function that will move things that are close to the clustering point a bit closer to it, and things that are remote even a bit further away.



          Here is another proposal in which the directions are correlated, and the sharp corners are gone. They appear above because some segments are super short.



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture
          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*60+(x+y)*120
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=10pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:0.2+0.8*rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
            – solisoc
            22 mins ago










          • @solisoc I added another option.
            – marmot
            12 mins ago










          • This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
            – solisoc
            4 mins ago














          up vote
          3
          down vote













          Something like this?



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture

          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*360
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=5pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here



          I first compute a main angle and then add fluctuations to it which are between -60 and +60. To make the objects cluster, I add a function that will move things that are close to the clustering point a bit closer to it, and things that are remote even a bit further away.



          Here is another proposal in which the directions are correlated, and the sharp corners are gone. They appear above because some segments are super short.



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture
          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*60+(x+y)*120
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=10pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:0.2+0.8*rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer






















          • This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
            – solisoc
            22 mins ago










          • @solisoc I added another option.
            – marmot
            12 mins ago










          • This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
            – solisoc
            4 mins ago












          up vote
          3
          down vote










          up vote
          3
          down vote









          Something like this?



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture

          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*360
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=5pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here



          I first compute a main angle and then add fluctuations to it which are between -60 and +60. To make the objects cluster, I add a function that will move things that are close to the clustering point a bit closer to it, and things that are remote even a bit further away.



          Here is another proposal in which the directions are correlated, and the sharp corners are gone. They appear above because some segments are super short.



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture
          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*60+(x+y)*120
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=10pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:0.2+0.8*rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here






          share|improve this answer














          Something like this?



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture

          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*360
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=5pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here



          I first compute a main angle and then add fluctuations to it which are between -60 and +60. To make the objects cluster, I add a function that will move things that are close to the clustering point a bit closer to it, and things that are remote even a bit further away.



          Here is another proposal in which the directions are correlated, and the sharp corners are gone. They appear above because some segments are super short.



          RequirePackageluatex85
          documentclassstandalone
          usepackagetikz
          usepackagepoisson
          begindocument
          edefmylistpoissonpointslist1050.3320

          begintikzpicture
          foreach x/y in mylist
          pgfmathsetmacromyrndrnd*60+(x+y)*120
          pgfmathsetmacromydistpow(x*x+y*y,1/3)/4
          draw[->, rounded corners=10pt] (mydist*x,mydist*y)
          foreach i in 1,...,3
          -- ++(myrnd+rnd*60:0.2+0.8*rnd)
          ;

          endtikzpicture
          enddocument


          enter image description here







          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited 12 mins ago

























          answered 45 mins ago









          marmot

          71.9k477153




          71.9k477153











          • This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
            – solisoc
            22 mins ago










          • @solisoc I added another option.
            – marmot
            12 mins ago










          • This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
            – solisoc
            4 mins ago
















          • This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
            – solisoc
            22 mins ago










          • @solisoc I added another option.
            – marmot
            12 mins ago










          • This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
            – solisoc
            4 mins ago















          This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
          – solisoc
          22 mins ago




          This is an intriguing approach, thanks. However, I can still see lines with sharp, abrupt kinks in your output. And while you do produce a nice cluster, the behaviour I'm looking for is not so much lines getting closer together as lines nearby a certain line resembling that certain line more (roughly). I may have been unclear about this in the question.
          – solisoc
          22 mins ago












          @solisoc I added another option.
          – marmot
          12 mins ago




          @solisoc I added another option.
          – marmot
          12 mins ago












          This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
          – solisoc
          4 mins ago




          This is very close to the desired output. However, I can still spot kinked lines in your output: I've circled two examples at the link below. Is there any way to eradicate them entirely? i.stack.imgur.com/HTbmo.jpg
          – solisoc
          4 mins ago

















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f458593%2fdrawing-many-random-paths-in-tikz%23new-answer', 'question_page');

          );

          Post as a guest













































































          Comments

          Popular posts from this blog

          Long meetings (6-7 hours a day): Being “babysat” by supervisor

          Is the Concept of Multiple Fantasy Races Scientifically Flawed? [closed]

          Confectionery