Skip to main content
deleted 14 characters in body
Source Link

After seeing your awesome contributions I really wanted to do it myself, and I'm pretty happy with the result:

enter image description here

It took me quite a bit of time because I'm very rusty when it comes to progamming. Also, the code is probably highly inefficient, so any suggestion will be very appreciated.

The main idea to genetare this is to first draw some random rectanglesquadrilaterals:

ClearAll["Global`*"]
a = .25;                     (*side length*)
c:=.15 RandomReal[{-1, 1}];  (*random shifting*)
d = .15;
n = 3;                       (*n+1 rectangles in the x direc.*)
m = 2;                       (*m+1 rectangles in the y direc.*)

s =  NestList[{#[[2]],#[[2]]+{a+c,0},#[[2]]+{a+c,a+c},#[[3]],#[[2]]} &,{{0,0},{a+c,0},{a+c,a+c},{0,a+c},{0,0}},n];
AppendTo[s,{#[[2]],#[[2]]+{a,0},#[[2]]+{a,a},#[[3]],#[[2]]}&[Last[s]]];
f[x_] := Module[{k=FoldList[{#1[[2]],#2[[3]],#2[[3]]+{c,a+c},#1[[3]],#1[[2]]}&,{#[[4]],#[[3]],#[[3]]+{c,a+c},#[[4]]+{c,a+c},#[[4]]}&[x[[1]]],Rest@x]},
                 k[[1,4,1]]=0;
                 k[[n+2,3,1]]=x[[-1,2,1]];
                 k];
q = NestList[f,s,m];
Table[q[[-1,j,3,2]]=q[[-1,j,4,2]]=(m+1)a,{j,1,n+2}];
q = Partition[#,2]&/@Partition[Flatten[q],10];
ListPlot[q,Joined->True,Axes->False]����������������>False]

enter image description here

The, I randomly turn some of these rectanglesquadrilaterals into triangles:

Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,3,1}]],q[[i]][[{3,4,1,3}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];
Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,4,1}]],q[[i]][[{2,3,4,2}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];��];

enter image description here

And finally, I generate the spirals inside each polygon:

g[x_]:=Fold[Append[#1,BSplineFunction[#1[[#2]],SplineDegree->1][d]]&,x,Partition[Range[150],2,1]]
ListPlot[g/@q,Joined->True,Axes->False,PlotStyle->Black,ImageSize->Large]���>Large]

This approach has many flaws compared to the other answers but the most important one is that one has to execute the code many times to get a decent result (because most of the times the polygons overlap).

After seeing your awesome contributions I really wanted to do it myself, and I'm pretty happy with the result:

enter image description here

It took me quite a bit of time because I'm very rusty when it comes to progamming. Also, the code is probably highly inefficient, so any suggestion will be very appreciated.

The main idea to genetare this is to first draw some random rectangles:

ClearAll["Global`*"]
a = .25;                     (*side length*)
c:=.15 RandomReal[{-1, 1}];  (*random shifting*)
d = .15;
n = 3;                       (*n+1 rectangles in the x direc.*)
m = 2;                       (*m+1 rectangles in the y direc.*)

s =  NestList[{#[[2]],#[[2]]+{a+c,0},#[[2]]+{a+c,a+c},#[[3]],#[[2]]} &,{{0,0},{a+c,0},{a+c,a+c},{0,a+c},{0,0}},n];
AppendTo[s,{#[[2]],#[[2]]+{a,0},#[[2]]+{a,a},#[[3]],#[[2]]}&[Last[s]]];
f[x_] := Module[{k=FoldList[{#1[[2]],#2[[3]],#2[[3]]+{c,a+c},#1[[3]],#1[[2]]}&,{#[[4]],#[[3]],#[[3]]+{c,a+c},#[[4]]+{c,a+c},#[[4]]}&[x[[1]]],Rest@x]},
                 k[[1,4,1]]=0;
                 k[[n+2,3,1]]=x[[-1,2,1]];
                 k];
q = NestList[f,s,m];
Table[q[[-1,j,3,2]]=q[[-1,j,4,2]]=(m+1)a,{j,1,n+2}];
q = Partition[#,2]&/@Partition[Flatten[q],10];
ListPlot[q,Joined->True,Axes->False]����������������

enter image description here

The, I randomly turn some of these rectangles into triangles:

Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,3,1}]],q[[i]][[{3,4,1,3}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];
Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,4,1}]],q[[i]][[{2,3,4,2}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];��

enter image description here

And finally, I generate the spirals inside each polygon:

g[x_]:=Fold[Append[#1,BSplineFunction[#1[[#2]],SplineDegree->1][d]]&,x,Partition[Range[150],2,1]]
ListPlot[g/@q,Joined->True,Axes->False,PlotStyle->Black,ImageSize->Large]���

This approach has many flaws compared to the other answers but the most important one is that one has to execute the code many times to get a decent result (because most of the times the polygons overlap).

After seeing your awesome contributions I really wanted to do it myself, and I'm pretty happy with the result:

enter image description here

It took me quite a bit of time because I'm very rusty when it comes to progamming. Also, the code is probably highly inefficient, so any suggestion will be very appreciated.

The main idea to genetare this is to first draw some random quadrilaterals:

ClearAll["Global`*"]
a = .25;                     (*side length*)
c:=.15 RandomReal[{-1, 1}];  (*random shifting*)
d = .15;
n = 3;                       (*n+1 rectangles in the x direc.*)
m = 2;                       (*m+1 rectangles in the y direc.*)

s =  NestList[{#[[2]],#[[2]]+{a+c,0},#[[2]]+{a+c,a+c},#[[3]],#[[2]]} &,{{0,0},{a+c,0},{a+c,a+c},{0,a+c},{0,0}},n];
AppendTo[s,{#[[2]],#[[2]]+{a,0},#[[2]]+{a,a},#[[3]],#[[2]]}&[Last[s]]];
f[x_] := Module[{k=FoldList[{#1[[2]],#2[[3]],#2[[3]]+{c,a+c},#1[[3]],#1[[2]]}&,{#[[4]],#[[3]],#[[3]]+{c,a+c},#[[4]]+{c,a+c},#[[4]]}&[x[[1]]],Rest@x]},
                 k[[1,4,1]]=0;
                 k[[n+2,3,1]]=x[[-1,2,1]];
                 k];
q = NestList[f,s,m];
Table[q[[-1,j,3,2]]=q[[-1,j,4,2]]=(m+1)a,{j,1,n+2}];
q = Partition[#,2]&/@Partition[Flatten[q],10];
ListPlot[q,Joined->True,Axes->False]

enter image description here

The, I randomly turn some of these quadrilaterals into triangles:

Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,3,1}]],q[[i]][[{3,4,1,3}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];
Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,4,1}]],q[[i]][[{2,3,4,2}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];

enter image description here

And finally, I generate the spirals inside each polygon:

g[x_]:=Fold[Append[#1,BSplineFunction[#1[[#2]],SplineDegree->1][d]]&,x,Partition[Range[150],2,1]]
ListPlot[g/@q,Joined->True,Axes->False,PlotStyle->Black,ImageSize->Large]

This approach has many flaws compared to the other answers but the most important one is that one has to execute the code many times to get a decent result (because most of the times the polygons overlap).

Source Link

After seeing your awesome contributions I really wanted to do it myself, and I'm pretty happy with the result:

enter image description here

It took me quite a bit of time because I'm very rusty when it comes to progamming. Also, the code is probably highly inefficient, so any suggestion will be very appreciated.

The main idea to genetare this is to first draw some random rectangles:

ClearAll["Global`*"]
a = .25;                     (*side length*)
c:=.15 RandomReal[{-1, 1}];  (*random shifting*)
d = .15;
n = 3;                       (*n+1 rectangles in the x direc.*)
m = 2;                       (*m+1 rectangles in the y direc.*)

s =  NestList[{#[[2]],#[[2]]+{a+c,0},#[[2]]+{a+c,a+c},#[[3]],#[[2]]} &,{{0,0},{a+c,0},{a+c,a+c},{0,a+c},{0,0}},n];
AppendTo[s,{#[[2]],#[[2]]+{a,0},#[[2]]+{a,a},#[[3]],#[[2]]}&[Last[s]]];
f[x_] := Module[{k=FoldList[{#1[[2]],#2[[3]],#2[[3]]+{c,a+c},#1[[3]],#1[[2]]}&,{#[[4]],#[[3]],#[[3]]+{c,a+c},#[[4]]+{c,a+c},#[[4]]}&[x[[1]]],Rest@x]},
                 k[[1,4,1]]=0;
                 k[[n+2,3,1]]=x[[-1,2,1]];
                 k];
q = NestList[f,s,m];
Table[q[[-1,j,3,2]]=q[[-1,j,4,2]]=(m+1)a,{j,1,n+2}];
q = Partition[#,2]&/@Partition[Flatten[q],10];
ListPlot[q,Joined->True,Axes->False]����������������

enter image description here

The, I randomly turn some of these rectangles into triangles:

Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,3,1}]],q[[i]][[{3,4,1,3}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];
Table[q=ReplacePart[q,i->Sequence@@{q[[i]][[{1,2,4,1}]],q[[i]][[{2,3,4,2}]]}];
   ,{i,RandomSample[Range[Length[q]],Floor[(n+1)(m+1)/3]]}];��

enter image description here

And finally, I generate the spirals inside each polygon:

g[x_]:=Fold[Append[#1,BSplineFunction[#1[[#2]],SplineDegree->1][d]]&,x,Partition[Range[150],2,1]]
ListPlot[g/@q,Joined->True,Axes->False,PlotStyle->Black,ImageSize->Large]���

This approach has many flaws compared to the other answers but the most important one is that one has to execute the code many times to get a decent result (because most of the times the polygons overlap).