Advertisement
Guest User

logarithmic spiral cogs

a guest
Apr 12th, 2020
462
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.21 KB | None | 0 0
  1. smoothstep[t_, t0_, t1_] := With[{tt = (t - t0)/(t1 - t0)},
  2. If[tt < 0, 0, If[tt > 1, 1, 6 tt^5 - 15 tt^4 + 10 tt^3]]
  3. ];
  4. a = 0.312;
  5. p[\[Theta]_] :=
  6. Exp[a \[Theta]] {Sin[\[Theta]], -Cos[\[Theta]]}/Exp[2 Pi a]
  7. radius[\[Theta]_] := (
  8. (E^(3 Re[
  9. a (-2 \[Pi] + \[Theta])]) (Abs[-a Cos[\[Theta]] +
  10. Sin[\[Theta]]]^2 + Abs[Cos[\[Theta]] + a Sin[\[Theta]]]^2)^(
  11. 3/2))/(\[Sqrt](-(a + a^3)^2 E^(4 a (-2 \[Pi] + \[Theta])) +
  12. E^(4 Re[a (-2 \[Pi] + \[Theta])]) (Abs[-a Cos[\[Theta]] +
  13. Sin[\[Theta]]]^2 +
  14. Abs[Cos[\[Theta]] + a Sin[\[Theta]]]^2) (Abs[
  15. Cos[\[Theta]] - a^2 Cos[\[Theta]] + 2 a Sin[\[Theta]]]^2 +
  16. Abs[2 a Cos[\[Theta]] + (-1 + a^2) Sin[\[Theta]]]^2)))
  17. );
  18. norm[\[Theta]_] := {E^(
  19. a (-2 \[Pi] + \[Theta])) (a Cos[\[Theta]] - Sin[\[Theta]]),
  20. E^(a (-2 \[Pi] + \[Theta])) (Cos[\[Theta]] + a Sin[\[Theta]])};
  21. \[Theta][s_] := Log[1 + (a E^(2 a \[Pi]) s)/Sqrt[1 + a^2]]/a;
  22.  
  23.  
  24. maxS = (Sqrt[1 + a^2] E^(-2 a \[Pi]) (-1 + E^(2 a \[Pi])))/a;
  25. rolledP[\[Theta]t_,
  26. s_] := (RotationMatrix[{norm[\[Theta][maxS Mod[s, 1]]], {0,
  27. 1}}].(p[\[Theta]t] - p[\[Theta][maxS Mod[ s, 1]]])
  28. + {maxS s, 0} +
  29. Floor[s] {-0.25592425837353455`, 0.8201906184288752`});
  30. offset[t_] := {maxS/2, 0} (1 - smoothstep[t, 2, 3]) +
  31. smoothstep[t, 2, 3] (
  32. rolledP[-1000, -smoothstep[t, 3, 4] (t - 3)] + {0.2, -0.45}
  33. );
  34. zoom[t_] := 1 + 0.5 smoothstep[t, 3, 4];
  35. proj[p_, t_] := (p - offset[t]) zoom[t];
  36. rolledP2[\[Theta]t_,
  37. s_] := (RotationMatrix[{norm[\[Theta][
  38. maxS Mod[s, 1]]], {0, -1}}].(p[\[Theta]t] -
  39. p[\[Theta][maxS Mod[s, 1]]])
  40. + {2.8 - maxS s, 0} -
  41. Floor[s] {-0.25592425837353455`, 0.8201906184288752`});
  42. frame[t_] := (
  43.  
  44. Show[
  45. Graphics[{
  46. White,
  47. {
  48. Opacity[1 - smoothstep[t, 2.5, 3]],
  49. Thickness[0.003],
  50. Line[{proj[{-10, 0}, t], proj[{10, 0}, t]}]
  51. },
  52. EdgeForm[], FaceForm[White],
  53. With[{tt =
  54. smoothstep[t, 0, 1] - smoothstep[t, 2, 3] -
  55. smoothstep[t, 3, 4] (t - 3)},
  56. {
  57. RGBColor[0.75, 0.22, 0.],
  58. Polygon[
  59. Table[(
  60. proj[
  61. rolledP[\[Theta]t, tt], t]
  62. ), {\[Theta]t, 0, 2 Pi, 0.1}]],
  63. {Black, Disk[proj[rolledP[-1000, tt], t], 0.04]},
  64. White, Thickness[0.004],
  65. If[tt > 0,
  66. Line[{proj[rolledP[-1000, 0], t],
  67. proj[rolledP[-1000, tt], t]}],
  68. {}
  69. ]
  70. }
  71. ],
  72. With[{tt = smoothstep[t, 1, 2] + smoothstep[t, 3, 4] (t - 3)},
  73. {
  74. RGBColor[0.19, 0.75, 1.],
  75. Polygon[
  76. Table[(
  77. proj[
  78. rolledP2[\[Theta]t, tt], t]
  79. ), {\[Theta]t, 0, 2 Pi, 0.1}]],
  80. {Black, Disk[proj[rolledP2[-1000, tt], t], 0.04]},
  81. {
  82. Opacity[1 - smoothstep[t, 2.5, 3]],
  83. Thickness[0.004],
  84. White,
  85. If[tt > 0,
  86.  
  87. Line[{proj[rolledP2[-1000, 0], t],
  88. proj[rolledP2[-1000, tt], t]}],
  89. {}
  90. ]
  91. }
  92. }
  93. ]
  94. }
  95. ],
  96. PlotRange -> 2.5, Background -> Black, ImageSize -> 500
  97. ]);
  98. Manipulate[
  99. frame[t],
  100. {t, 0, 6}
  101. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement