0
$\begingroup$

What are the issues with the dynamic image code generated by sine curves? How to modify and improve it?

BX[t_] := 
  Module[{g1, g2, g3, g4, r}, 
   g1 = ParametricPlot[{{Cos[2 \[Pi] r], 
       Sin[2 \[Pi] r]}, {2 + \[Pi] t r/64, Sin[\[Pi] t r/64]}}, {r, 0,
       1}, PlotStyle -> {RGBColor[0, 0, 1]}, 
     Ticks -> {{-1, 0, 1, 2, 2 + \[Pi]/2, 2 + \[Pi], 2 + 3 \[Pi]/2, 
        2 + 2 \[Pi]}, {-1, 0, 1}}, 
     PlotRange -> {{-1, 2 + 2 \[Pi]}, {-1, 1}}]; 
   g2 = ParametricPlot[{{r + Cos[\[Pi] t/64], 
       r Sin[\[Pi] t/64]}, {r (2 + \[Pi] t/64) + (1 - 
           r) Cos[\[Pi] t/64], Sin[\[Pi] t/64]}}, {r, 0, 1}, 
     PlotStyle -> {RGBColor[0, 1, 0]}]; 
   g3 = Graphics[{PointSize[0.04], RGBColor[1, 0, 0], 
      Point[{2 + \[Pi] t/64, Sin[\[Pi] t/64]}]}]; 
   g4 = Graphics[{PointSize[0.04], RGBColor[1, 0, 0], 
      Point[{Cos[\[Pi] t/64], Sin[\[Pi] t/64]}]}]; 
   Show[g1, g2, g3, g4, AspectRatio -> Automatic]];
Animate[BX[t], {t, 0, 128, 1}]

enter image description here

How to make the code more concise and the graphics more aesthetically pleasing

$\endgroup$
3
  • $\begingroup$ Could you make the question more specific? What modifications and improvements are you looking for? $\endgroup$
    – MelaGo
    Commented Jan 2 at 2:32
  • $\begingroup$ @MelaGo How to make the code more concise and the graphics more aesthetically pleasing $\endgroup$
    – csn899
    Commented Jan 2 at 3:06
  • $\begingroup$ Adding PlotRangePadding -> 1 in g1 will prevent the clipping $\endgroup$
    – MelaGo
    Commented Jan 2 at 4:05

1 Answer 1

1
$\begingroup$

You have the x coordinate of g2 wrong.

BX[t_] := 
  Module[{g1, g2, g3, g4, r}, 
   g1 = ParametricPlot[{{Cos[2 \[Pi] r], 
       Sin[2 \[Pi] r]}, {2 + \[Pi] t r/64, Sin[\[Pi] t r/64]}}, {r, 0,
       1}, PlotStyle -> {RGBColor[0, 0, 1]}, 
     Ticks -> {{-1, 0, 1, 2, 2 + \[Pi]/2, 2 + \[Pi], 2 + 3 \[Pi]/2, 
        2 + 2 \[Pi]}, {-1, 0, 1}}, 
     PlotRange -> {{-1, 2 + 2 \[Pi]}, {-1, 1}}];
   g2 = ParametricPlot[{{r Cos[\[Pi] t/64], 
       r  Sin[\[Pi] t/64]}, {r (2 + \[Pi] t/64) + (1 - 
           r) Cos[\[Pi] t/64], Sin[\[Pi] t/64]}}, {r, 0, 1}, 
     PlotStyle -> {RGBColor[0, 1, 0]}];
   g3 = Graphics[{PointSize[0.04], RGBColor[1, 0, 0], 
      Point[{2 + \[Pi] t/64, Sin[\[Pi] t/64]}]}];
   g4 = Graphics[{PointSize[0.04], RGBColor[1, 0, 0], 
      Point[{Cos[\[Pi] t/64], Sin[\[Pi] t/64]}]}];
   Show[g1, g2, g3, g4, AspectRatio -> Automatic]];
Animate[BX[t], {t, 0, 128, 1}]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.