Advertisement
Matthen

Cruithne

Sep 19th, 2013
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.69 KB | None | 0 0
  1. Clear[orbit];
  2. orbit[{x0_, y0_}, {v0x_, v0y_}] :=
  3. orbit[{x0, y0}, {v0x, v0y}] = Module[{eqns, soln, x, y, t},
  4. eqns =
  5. {x[0] == x0, y[0] == y0, x'[0] == v0x, y'[0] == v0y,
  6. x''[t] == -x[t]/(x[t]^2 + y[t]^2)^1.5,
  7. y''[t] == -y[t]/(x[t]^2 + y[t]^2)^1.5};
  8. soln = {x[t], y[t]} /.
  9. First[NDSolve[eqns, {x[t], y[t]}, {t, 0, 10}]];
  10. (soln /. {t -> #}) &
  11. ];
  12. eartht = 6.72801;
  13. earth = {-Cos[2 Pi #/eartht], Sin[2 Pi #/eartht]} &;
  14. cruithne1 = orbit[{-1.2, 1.2}, {0.4, 0.4}];
  15. cruithne[t_] := cruithne1[eartht t/5.76]
  16. earthframe[{x_, y_}, t_] := RotationMatrix[2 Pi t /eartht].{x, y};
  17. Manipulate[
  18. Show[
  19. If[T > eartht,
  20. ParametricPlot[{earthframe[cruithne[eartht - t], eartht - t]}, {t,
  21. 0, 2 eartht - T}, PlotRange -> 1.8, Background -> Black,
  22. Axes -> None, PlotStyle -> Directive[Thick, White]]
  23. ,
  24. ParametricPlot[{earthframe[cruithne[t], t]}, {t, 0, T},
  25. PlotRange -> 1.8, Background -> Black, Axes -> None,
  26. PlotStyle -> Directive[Thick, White]]
  27. ],
  28. ParametricPlot[{earth[t], earthframe[cruithne[t], T]}, {t, 0,
  29. eartht},
  30. PlotStyle -> {Directive[Thick, RGBColor[0.6, 0.6, 0.8]],
  31. Directive[Thick, Darker@Red]}],
  32. Graphics[{
  33. {White, Dotted,
  34. Table[
  35. Line[{earthframe[{-10, y}, T],
  36. earthframe[{10, y}, T]}], {y, -10, 10, 0.5}],
  37. Table[
  38. Line[{earthframe[{x, -10}, T],
  39. earthframe[{x, 10}, T]}], {x, -10, 10, 0.5}]
  40. },
  41.  
  42. {Yellow, Disk[earthframe[{0, 0}, T], 0.1],
  43. EdgeForm[Black],
  44. RGBColor[0.7, 0.8, 1.0], Disk[earthframe[earth[T], T], 0.07],
  45. Red, Disk[earthframe[cruithne[Mod[T, eartht]], T], 0.04]}
  46. }]
  47. ],
  48. {T, 0.001, 2 eartht - 0.001}]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement