Advertisement
Matthen

Retrograde Motion

Jun 4th, 2011
316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. T = 2.59;
  2. r = 1.524;
  3. stars = Partition[
  4. Riffle[RandomReal[{-2, 2}, 20], RandomReal[{2.5, 3.5}, 20]], 2];
  5. Project[{ax_, ay_}, {bx_, by_}] :=
  6. Module[{\[Lambda] = (3 - ay)/(
  7. by - ay)}, {ax + \[Lambda] bx - \[Lambda] ax, 3}];
  8. mars[t_] := r {Sin[2 Pi t/T], Cos[2 Pi t/T]};
  9. earth[t_] := {Sin[2 Pi t], Cos[2 Pi t]};
  10. Manipulate[
  11. Show[Graphics[Join[
  12. { RGBColor[1, 0.2, 0], Disk[mars[t], 0.05],
  13. RGBColor[0, 0.6, 1],
  14. Disk[earth[t], 0.05],
  15. If[Abs[t] <= 0.38,
  16. Line[{earth[t], Project[earth[t], mars[t]] + {0, t}}],
  17. Opacity[1]],
  18. Blend[{Yellow, Orange}, 0.2],
  19. Disk[{0, 0}, 0.1], White, Point[stars]}
  20. ], PlotRange -> {{-2, 2}, {-2, 4}}],
  21. ParametricPlot[{Project[earth[t], mars[t]][[1]], t + 3}, {t, -0.38,
  22. 0.38}, Axes -> None, PlotStyle -> RGBColor[1, 0.2, 0]]
  23. , Background -> Black]
  24. , {t, -1, 1 }]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement