Matthen

Paint curves

Feb 26th, 2015
747
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. \[Theta]step = Pi/2;
  2. nmax = 3;
  3. point[r_, \[Theta]_] :=
  4. With[{\[Theta]t = Mod[\[Theta], \[Theta]step, -\[Theta]step/2],
  5. n = Floor[\[Theta]/\[Theta]step + 1/2]},
  6. 2 r {Cos[\[Theta]t] (-1)^n,
  7. Sin[-\[Theta]t]} - {(-1)^(n) Cos[\[Theta]step/2],
  8. 2 n Sin[\[Theta]step/2]}
  9. ];
  10. frame[\[Theta]max_] := (Show[
  11. Join[{
  12. Graphics[{
  13. EdgeForm[], FaceForm[RGBColor[0.0, 0.3, 0.9]],
  14. Rectangle[{-Cos[\[Theta]step/2], -2 nmax Sin[\[Theta]step/
  15. 2]}, {Cos[\[Theta]step/2], 0}]
  16. },
  17. PlotRange -> {
  18. 1.5 {-1, 1}, {0.1, -2 nmax Sin[\[Theta]step/2] - 0.1}}
  19. ]
  20. },
  21. Table[
  22. ParametricPlot[
  23. point[r, \[Theta]]
  24. , {\[Theta], 0, \[Theta]max},
  25. PlotStyle ->
  26. Lighter@ColorData["RedBlueTones"][1 - 4 r (1 - r)],
  27. Exclusions -> Mod[\[Theta], \[Theta]step] == \[Theta]step/2,
  28. Axes -> None],
  29. {r, 0, 1, 1/30}
  30. ],
  31. {Graphics[{
  32. {FaceForm[White], EdgeForm[],
  33. Rectangle[{-1.5,
  34. 0}, {-Cos[\[Theta]step/2], -2 nmax Sin[\[Theta]step/2]}],
  35. Rectangle[{Cos[\[Theta]step/
  36. 2], -2 nmax Sin[\[Theta]step/2]}, {1.5, 0}]},
  37. {Thick, Darker@Red,
  38. Line[
  39. Table[
  40. point[r, \[Theta]max],
  41. {r, 0, 1, 1/30}
  42. ]
  43. ]
  44. }
  45. }
  46. ]}
  47. ]]);
  48. Manipulate[
  49. frame[\[Theta]max],
  50. {\[Theta]max, 0.01, \[Theta]step nmax}
  51. ]
Advertisement
Add Comment
Please, Sign In to add comment