Drawing many random paths in TikZ
Clash 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.
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
add a comment |Â
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.
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
add a comment |Â
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.
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
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.
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
tikz-pgf luatex diagrams random randomwalk
asked 1 hour ago
solisoc
615
615
add a comment |Â
add a comment |Â
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
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
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
26 mins ago
@solisoc I added another option.
â marmot
15 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
7 mins ago
add a comment |Â
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
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
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
26 mins ago
@solisoc I added another option.
â marmot
15 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
7 mins ago
add a comment |Â
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
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
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
26 mins ago
@solisoc I added another option.
â marmot
15 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
7 mins ago
add a comment |Â
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
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
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
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
edited 15 mins ago
answered 48 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
26 mins ago
@solisoc I added another option.
â marmot
15 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
7 mins ago
add a comment |Â
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
26 mins ago
@solisoc I added another option.
â marmot
15 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
7 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
26 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
26 mins ago
@solisoc I added another option.
â marmot
15 mins ago
@solisoc I added another option.
â marmot
15 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
7 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
7 mins ago
add a comment |Â
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
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
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
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
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