Advertisement
Matthen

Planets in 2012

Apr 13th, 2012
345
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. planets = Join[{"Sun"}, AstronomicalData["Planet"]];
  2. planets = Select[planets, # != "Earth" &];
  3. t0 = AbsoluteTime[{2012, 1, 1, 0, 0, 0}];
  4. t1 = AbsoluteTime[{2013, 1, 1, 0, 0, 0}];
  5. r = Norm[AstronomicalData["Uranus", "Position"]];
  6. n = {0, 0, 1};
  7. pos[p_, t_] := (AstronomicalData[p, {"Position", DateList[t]}])/r;
  8. pi[p_, t_] :=
  9. Module[{x = pos[p, t], u = n,
  10. v = (pos["Sun", t] - pos["Earth", t])\[Cross]n, X},
  11. v = v/Norm[v];
  12. X = {v.x, u.x}
  13. ];
  14. pi2[p_, t_] := Module[{X = pi[p, t]},
  15. If[Norm[X] == 0,
  16. X,
  17. (X/Norm[X]) VectorAngle[pos["Earth", t],
  18. pos[p, t]] (Norm[pos[p, t]]^0.3)/Pi
  19. ]
  20. ]
  21. Clear[planetimg];
  22. planetimg[p_] :=
  23. planetimg[p] = Module[{img = AstronomicalData[p, "Image"]},
  24. SetAlphaChannel[img,
  25. ImageApply[If[Norm[#] > 0.5, {1, 1, 1}, #] &, img]]
  26. ];
  27.  
  28. frame[t_] :=
  29. Graphics[
  30. {Table[{White,
  31. Inset[Rotate[Style[Text[p], Large], Pi/2],
  32. pi2[p, t] + {0, 0.2}, {Center, Bottom}],
  33. Inset[planetimg[p], pi2[p, t], {Center, Center}, 0.2]}, {p,
  34. planets}
  35. ]
  36. ,
  37. White,
  38. Text[DateString[
  39. DateList[t], {"Day", " ", "MonthName", " ", "Year"}], {0, -0.1}]
  40. }
  41. , PlotRange -> {{-1.2, 1.2}, {-0.2, 1}}, Background -> Black];
  42.  
  43. anim = Table[frame[t], {t, t0, t1, (t1 - t0)/60}];
  44.  
  45. Export["planets.gif", anim]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement