Fantastic pattern and Hats off to the creator of this pic.
what code or tool was used to generate this?
See the code below Asif Ahmed 1.RollSub[p_, dir_, \[Theta]_] := Module[{sq, rp},2. sq = {p, p + dir, p + dir + RotationMatrix[Pi/2].dir,3. p + RotationMatrix[Pi/2].dir};4. sq = Map[RotationMatrix[-\[Theta]].(# - (p + dir)) + (p + dir) &,5. sq];6. sq = Map[# &, sq]7. ];8.Roll[p_, dir_, \[Theta]_] :=9. Module[{n = Floor[2 \[Theta]/Pi], sq0, sq},10. sq0 = RollSub[p, dir, 0];11. sq = Nest[RotateLeft[RollSub[#[[1]], dir, Pi/2]] &, sq0, n];12. RollSub[sq[[1]], dir, \[Theta] - n Pi/2]13. ];14.RollAround[\[Theta]_] := Module[{p, dir, th, n, m},15. n = Mod[Floor[\[Theta]/Pi], 4] + 1;16. p = {{0, 0}, {3, 0}, {3, 3}, {0, 3}}[[n]];17. dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}[[n]];18. th = \[Theta] - Pi (n - 1);19. m = Mod[Floor[2 \[Theta]/Pi], 4] + 1;20. Nest[RotateRight, Roll[p, dir, th],21. 1/4 (-3 - (-1)^m + 6 m) + 2 Floor[(n + 1)/2]]22. ];23.Manipulate[24. Show[Graphics[{25. EdgeForm[Directive[Thick, RGBColor[0.1, 0.2, 0.1]]], FaceForm[],26. Rectangle[{0, 0}, {3, 3}],27. EdgeForm[Thick],28. Polygon[RollAround[Mod[\[Theta], 4 Pi]]]29. }, PlotRange -> {{-0.1, 3.1}, {-0.1, 3.1}}],30. 31. ParametricPlot[32. RollAround[t], {t, If[\[Theta] < 4 Pi, 0, Mod[\[Theta], 4 Pi]],33. If[\[Theta] < 4 Pi, Max[\[Theta], 0.01], 4 Pi - 0.01]},34. PlotStyle -> RGBColor[0.450385`, 0.157961`, 0.217975`]]35. , ImageSize -> 320]36. , {\[Theta], 0, 8 Pi - 0.01}]Raw data:RollSub[p_, dir_, \[Theta]_] := Module[{sq, rp}, sq = {p, p + dir, p + dir + RotationMatrix[Pi/2].dir, p + RotationMatrix[Pi/2].dir}; sq = Map[RotationMatrix[-\[Theta]].(# - (p + dir)) + (p + dir) &, sq]; sq = Map[# &, sq] ];Roll[p_, dir_, \[Theta]_] := Module[{n = Floor[2 \[Theta]/Pi], sq0, sq}, sq0 = RollSub[p, dir, 0]; sq = Nest[RotateLeft[RollSub[#[[1]], dir, Pi/2]] &, sq0, n]; RollSub[sq[[1]], dir, \[Theta] - n Pi/2] ];RollAround[\[Theta]_] := Module[{p, dir, th, n, m}, n = Mod[Floor[\[Theta]/Pi], 4] + 1; p = {{0, 0}, {3, 0}, {3, 3}, {0, 3}}[[n]]; dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}[[n]]; th = \[Theta] - Pi (n - 1); m = Mod[Floor[2 \[Theta]/Pi], 4] + 1; Nest[RotateRight, Roll[p, dir, th], 1/4 (-3 - (-1)^m + 6 m) + 2 Floor[(n + 1)/2]] ];Manipulate[ Show[Graphics[{ EdgeForm[Directive[Thick, RGBColor[0.1, 0.2, 0.1]]], FaceForm[], Rectangle[{0, 0}, {3, 3}], EdgeForm[Thick], Polygon[RollAround[Mod[\[Theta], 4 Pi]]] }, PlotRange -> {{-0.1, 3.1}, {-0.1, 3.1}}], ParametricPlot[ RollAround[t], {t, If[\[Theta] < 4 Pi, 0, Mod[\[Theta], 4 Pi]], If[\[Theta] < 4 Pi, Max[\[Theta], 0.01], 4 Pi - 0.01]}, PlotStyle -> RGBColor[0.450385`, 0.157961`, 0.217975`]] , ImageSize -> 320] , {\[Theta], 0, 8 Pi - 0.01}]
Matlab is fun =)
Objects are so kool.
Welcome to the Spirograph of the 80s
Fantastic pattern and Hats off to the creator of this pic.
ReplyDeletewhat code or tool was used to generate this?
ReplyDeleteSee the code below Asif Ahmed
ReplyDelete1.
RollSub[p_, dir_, \[Theta]_] := Module[{sq, rp},
2.
sq = {p, p + dir, p + dir + RotationMatrix[Pi/2].dir,
3.
p + RotationMatrix[Pi/2].dir};
4.
sq = Map[RotationMatrix[-\[Theta]].(# - (p + dir)) + (p + dir) &,
5.
sq];
6.
sq = Map[# &, sq]
7.
];
8.
Roll[p_, dir_, \[Theta]_] :=
9.
Module[{n = Floor[2 \[Theta]/Pi], sq0, sq},
10.
sq0 = RollSub[p, dir, 0];
11.
sq = Nest[RotateLeft[RollSub[#[[1]], dir, Pi/2]] &, sq0, n];
12.
RollSub[sq[[1]], dir, \[Theta] - n Pi/2]
13.
];
14.
RollAround[\[Theta]_] := Module[{p, dir, th, n, m},
15.
n = Mod[Floor[\[Theta]/Pi], 4] + 1;
16.
p = {{0, 0}, {3, 0}, {3, 3}, {0, 3}}[[n]];
17.
dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}[[n]];
18.
th = \[Theta] - Pi (n - 1);
19.
m = Mod[Floor[2 \[Theta]/Pi], 4] + 1;
20.
Nest[RotateRight, Roll[p, dir, th],
21.
1/4 (-3 - (-1)^m + 6 m) + 2 Floor[(n + 1)/2]]
22.
];
23.
Manipulate[
24.
Show[Graphics[{
25.
EdgeForm[Directive[Thick, RGBColor[0.1, 0.2, 0.1]]], FaceForm[],
26.
Rectangle[{0, 0}, {3, 3}],
27.
EdgeForm[Thick],
28.
Polygon[RollAround[Mod[\[Theta], 4 Pi]]]
29.
}, PlotRange -> {{-0.1, 3.1}, {-0.1, 3.1}}],
30.
31.
ParametricPlot[
32.
RollAround[t], {t, If[\[Theta] < 4 Pi, 0, Mod[\[Theta], 4 Pi]],
33.
If[\[Theta] < 4 Pi, Max[\[Theta], 0.01], 4 Pi - 0.01]},
34.
PlotStyle -> RGBColor[0.450385`, 0.157961`, 0.217975`]]
35.
, ImageSize -> 320]
36.
, {\[Theta], 0, 8 Pi - 0.01}]
Raw data:
RollSub[p_, dir_, \[Theta]_] := Module[{sq, rp},
sq = {p, p + dir, p + dir + RotationMatrix[Pi/2].dir,
p + RotationMatrix[Pi/2].dir};
sq = Map[RotationMatrix[-\[Theta]].(# - (p + dir)) + (p + dir) &,
sq];
sq = Map[# &, sq]
];
Roll[p_, dir_, \[Theta]_] :=
Module[{n = Floor[2 \[Theta]/Pi], sq0, sq},
sq0 = RollSub[p, dir, 0];
sq = Nest[RotateLeft[RollSub[#[[1]], dir, Pi/2]] &, sq0, n];
RollSub[sq[[1]], dir, \[Theta] - n Pi/2]
];
RollAround[\[Theta]_] := Module[{p, dir, th, n, m},
n = Mod[Floor[\[Theta]/Pi], 4] + 1;
p = {{0, 0}, {3, 0}, {3, 3}, {0, 3}}[[n]];
dir = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}}[[n]];
th = \[Theta] - Pi (n - 1);
m = Mod[Floor[2 \[Theta]/Pi], 4] + 1;
Nest[RotateRight, Roll[p, dir, th],
1/4 (-3 - (-1)^m + 6 m) + 2 Floor[(n + 1)/2]]
];
Manipulate[
Show[Graphics[{
EdgeForm[Directive[Thick, RGBColor[0.1, 0.2, 0.1]]], FaceForm[],
Rectangle[{0, 0}, {3, 3}],
EdgeForm[Thick],
Polygon[RollAround[Mod[\[Theta], 4 Pi]]]
}, PlotRange -> {{-0.1, 3.1}, {-0.1, 3.1}}],
ParametricPlot[
RollAround[t], {t, If[\[Theta] < 4 Pi, 0, Mod[\[Theta], 4 Pi]],
If[\[Theta] < 4 Pi, Max[\[Theta], 0.01], 4 Pi - 0.01]},
PlotStyle -> RGBColor[0.450385`, 0.157961`, 0.217975`]]
, ImageSize -> 320]
, {\[Theta], 0, 8 Pi - 0.01}]
Matlab is fun =)
ReplyDeleteObjects are so kool.
ReplyDeleteWelcome to the Spirograph of the 80s
ReplyDelete