%% $Id: pst-solarsystem.tex 620 2012-01-01 14:09:57Z herbert $
%%
%% This is file `pst-solarsystem.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-solarsystem.tex'
%%
%% Manuel Luque <manuel -> perce.de>
%% Herbert Voss <herbert -> dante.de>
%%
%% This program can be redistributed and/or modified under the terms
%% of the LaTeX Project Public License Distributed from CTAN archives
%% in directory macros/latex/base/lppl.txt.
%%
%% DESCRIPTION:
%%   `pst-solarsystem' is a PSTricks package for plotting the solar system
%%                     for a specific date
%%
\csname PSTSOLARSYSTEMELoaded\endcsname
\let\PSTSOLARSYSTEMELoaded\endinput
% Requires some packages
\ifx\PSTricksLoaded\endinput\else \input pstricks \fi
\ifx\PSTnodesLoaded\endinput\else \input pst-node \fi
\ifx\PSTplotLoaded\endinput\else  \input pst-plot \fi
\ifx\PSTthreeDLoaded\endinput\else\input pst-3d   \fi
\ifx\GradientLoaded\endinput\else \input pst-grad \fi
\ifx\PSTtoolsLoaded\endinput\else \input pst-tools\fi
\ifx\PSTXKeyLoaded\endinput\else  \input pst-xkey \fi
\def\fileversion{0.12}
\def\filedate{2012/01/01}
\message{`PSTSOLARSYSTEME' v\fileversion, \filedate}
%
\pstheader{pst-solarsystem.pro}
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
%
\pst@addfams{pst-solarsystem}
\define@key[psset]{pst-solarsystem}{Day}[\number\day]{\def\psk@SolarSystemD{#1}}
\define@key[psset]{pst-solarsystem}{Month}[\number\month]{\def\psk@SolarSystemM{#1}}
\define@key[psset]{pst-solarsystem}{Year}[\number\year]{\def\psk@SolarSystemY{#1}}
\define@key[psset]{pst-solarsystem}{Hour}[12]{\def\psk@SolarSystemH{#1}}
\define@key[psset]{pst-solarsystem}{Minute}[0]{\def\psk@SolarSystemMi{#1}}
\define@key[psset]{pst-solarsystem}{Second}[0]{\def\psk@SolarSystemS{#1}}
%
\psset{Day=\number\day,Month=\number\month,Year=\number\year,Hour=12,Minute=0,Second=0}
%% === show the results ---------------------
\define@boolkey[psset]{pst-solarsystem}[Pst@]{values}[true]{}
\psset[pst-solarsystem]{values}

\SpecialCoor
\newpsstyle{planetes}{linestyle=none,fillstyle=gradient,gradmidpoint=0,gradend=white,GradientCircle}
\newcommand{\Jupiter}{%
  \psclip{\pscircle[fillstyle=solid,fillcolor=yellow]{1.5}}
  \psset{fillstyle=solid,fillcolor={[cmyk]{0 0.2 0.4 0}},linestyle=none}
    \psframe(-2,.6)(2,1)
    \psframe(-2,0.45)(2,0.52)
    \psframe(-2,.05)(2,.3)
    \psframe(-2,-0.35)(2,-0.2)
    \psframe(-2,-0.9)(2,-.5)
  \endpsclip
  \psellipse[fillstyle=solid,fillcolor={[cmyk]{0 0.4 0.6 0}},linestyle=none](-0.3,-0.6)(0.35,0.2)
  \pscircle{1.5}}
%
\newcommand{\Saturne}{%
  \psellipse(3,0.7)
  \psellipse[linewidth=2\pslinewidth](3.5,1)
  \psellipse(4,1.2)
  \pscircle[fillstyle=solid](0,0){1.5}
  \psclip{\pscircle(0,0){1.5}}
    \psellipticarc(3,0.7){180}{0}
    \psellipticarc[linewidth=2\pslinewidth](3.5,1){180}{0}
    \psellipticarc(4,1.2){180}{0}
  \endpsclip
  \psellipticarc(0,0.5)(1.414,0.25){180}{0}
  \psellipticarc(0,1.25)(0.829,0.2){180}{0}
  \psellipticarc(0,-1)(1.118,0.2){180}{0}
  \psellipticarc(0,0)(1.5,0.27){180}{0}}
%
\psset{viewpoint=0 0 1}
%
\def\SolarSystem{\pst@object{SolarSystem}}
\def\SolarSystem@i{{%
  \pst@killglue%
  \use@par%
  \begin{pspicture}(-8,-8)(8,8)
  \psgrid[subgriddiv=0,gridcolor=lightgray,griddots=10,gridlabels=0pt]%
  \pstVerb{%
   /JOUR \psk@SolarSystemD\space def
   /MOIS \psk@SolarSystemM\space def
   /AN \psk@SolarSystemY\space def
   /HEURE \psk@SolarSystemH\space def
   /MINUTE \psk@SolarSystemMi\space def
   /SECONDE \psk@SolarSystemS\space def
   %%%% Calcul du millénaire Julien ---------------------
   /lesMois [0 31 59 90 120 151 181 212 243 273 304 334] def
   /EcartJours {lesMois MOIS 1 sub get JOUR add HEURE MINUTE 60 div add SECONDE 3600 div add 24 div add 1 sub} def
   /EcartAn {AN 4 div AN 4 div floor sub cvi} bind def
   EcartAn 0 eq {/EcartAn 1 def} if
   EcartAn 1 eq {MOIS 2 gt {/EcartJours EcartJours 1 add def}if} if
   /T {AN 2000 sub 365.25 mul 0.5 add EcartJours add EcartAn sub 365250 div} bind def
   /T2 {T dup mul} bind def
   /T3 {T2 T mul} bind def
  }%
  \rput(0,8){\psk@SolarSystemD/\psk@SolarSystemM/\psk@SolarSystemY}%
  \ThreeDput{%
    % \psframe[fillstyle=gradient,gradbegin=cyan,gradend=white](-7,-7)(7,7)
    \multido{\r=22.5+45}{8}{\psline[linecolor=yellow](1;\r)}%
    \psline[linestyle=dotted]{->}(-7,0)(7,0)
    \uput[0](7,0){$\mathbf{\gamma}$}
    \uput[90](7,0){0\textsuperscript{o}}
    \uput[90](0,7){90\textsuperscript{o}}
    \uput[180](-7,0){180\textsuperscript{o}}
    \uput[270](0,-6.9){270\textsuperscript{o}}
    \psline[linestyle=dotted](0,-7)(0,7)}%
    \pscircle[linestyle=none,fillstyle=gradient,gradmidpoint=0,gradend=yellow,GradientCircle=true,gradbegin=gray]{0.5}%
    {\psset{unit=2}
     % Mercure
     \pstVerb{%
       merLM merKA merHA merQ merP orbitalparameters
       amer /radius exch 1 E dup mul sub mul
       1 E LO LP sub cos mul add div def }%
    \ThreeDput{%
      \psplot[polarplot,plotpoints=361,linecolor=red]{LN }{LN 180 add}{%
        amer 1 E dup mul sub mul 1 E x LP sub cos mul add div}%
      \psplot[polarplot,plotpoints=361,linestyle=dashed,linecolor=blue]{180 LN add}{LN 360 add}{%
        amer 1 E dup mul sub mul 1 E x LP sub cos mul add div}%
      \pnode(! radius LO cos mul radius LO sin mul){M}
    }%
  \rput(M){\psset{unit=2}%
    \pscircle[style=planetes,gradbegin=black,GradientPos={(0.01,0.01)}]{0.02}
    \uput[u](0,0){\footnotesize\textsf{Mercure}}}
  \ifPst@values
    \rput(-2.5,-4.25){\psPrintValue{LO}}
    \rput(-2.5,-4.75){\psPrintValue{LA}}
    \rput(-2.5,-5.25){\psPrintValue{radius}}
  \fi
% Venus
  \pstVerb{%
    venLM venKA venHA venQ venP orbitalparameters
    aven /radius exch 1 E dup mul sub mul
    1 E LO LP sub cos mul add div def }%
  \ThreeDput{%
    \psplot[polarplot,plotpoints=361,linecolor=red]{LN }{LN 180 add}{%
      aven 1 E dup mul sub mul   1 E x LP sub cos mul add div}
    \psplot[polarplot=true,plotpoints=361,linestyle=dashed,linecolor=blue]{180 LN add}{LN 360 add}{%
      aven 1 E dup mul sub mul
      1 E x LP sub cos mul add div}%
    \pnode(! radius LO cos mul radius LO sin mul){V}
  }%
  \rput(V){\psset{unit=2}%
    \pscircle[style=planetes,gradbegin={[HTML]{6F2D0A}},GradientPos={(0.03,0.03)}]{0.051}%
    \uput{0.07}[u](0,0){\footnotesize\textsf{V\'enus}}}
  \ifPst@values
    \rput(-1.5,-4.25){\psPrintValue{LO}}
    \rput(-1.5,-4.75){\psPrintValue{LA}}
    \rput(-1.5,-5.25){\psPrintValue{radius}}
  \fi
% Earth
  \pstVerb{%
    earLM earKA earHA earQ earP orbitalparameters
    aear /radius exch 1 E dup mul sub mul
    1 E LO LP sub cos mul add div def
  }%
  \ThreeDput{%
    \psplot[polarplot=true,plotpoints=361,linecolor=red]{0}{360}{%
      aear 1 E dup mul sub mul
      1 E x LP sub cos mul add div}
    \pnode(! radius LO cos mul radius LO sin mul){Terre}}
  \rput(Terre){\psset{unit=2}%
  \pscircle[style=planetes,gradbegin=blue,GradientPos={(0.013,0.03)}]{0.0536}%
  \uput{0.08}[u](0,0){\footnotesize\textsf{Terre}}}%
  \ifPst@values
    \rput(-0.5,-4.25){\psPrintValue{LO}}
    \rput(-0.5,-4.75){\psPrintValue{0.000}}
    \rput(-0.5,-5.25){\psPrintValue{radius}}
  \fi
% Mars
\pstVerb{%
marLM marKA marHA marQ marP orbitalparameters
 amar /radius exch 1 E dup mul sub mul
 1 E LO LP sub cos mul add div def
 }%
 \ThreeDput{%
 \psplot[polarplot=true,plotpoints=361,linecolor=red]{LN }{LN 180 add}{%
 amar 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
 \psplot[polarplot=true,plotpoints=361,linestyle=dashed,linecolor=blue]{180 LN add}{LN 360 add}{%
 amar 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
\pnode(! radius LO cos mul radius LO sin mul){Mars}}
\rput(Mars){%
  \psset{unit=2}\pscircle[style=planetes,gradbegin=red,GradientPos={(0.01,0.01)}]{0.02857}
  \uput[u](0,0){\footnotesize\textsf{Mars}}}%
\ifPst@values
\rput(0.5,-4.25){\psPrintValue{LO}}
\rput(0.5,-4.75){\psPrintValue{LA}}
\rput(0.5,-5.25){\psPrintValue{radius}}
\fi
% Jupiter
\pstVerb{%
 jupLM jupKA jupHA jupQ jupP orbitalparameters
 /aJ ajup def
 aJ /radius exch 1 E dup mul sub mul
 1 E LO LP sub cos mul add div def
 }%
 \ThreeDput{%
 \psset{unit=0.5}
 \psplot[polarplot=true,plotpoints=361,linecolor=red]{LN }{LN 180 add}{%
 aJ 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
 \psplot[polarplot=true,plotpoints=361,linestyle=dashed,linecolor=blue]{180 LN add}{LN 360 add}{%
 aJ 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
\pnode(! radius LO cos mul radius LO sin mul){Jupiter}
}%
\rput(Jupiter){\psset{unit=0.1}\Jupiter%
  \uput{1.5}[u](0,0){\footnotesize\textsf{Jupiter}}}%
\ifPst@values
\rput(1.5,-4.25){\psPrintValue{LO}}
\rput(1.5,-4.75){\psPrintValue{LA}}
\rput(1.5,-5.25){\psPrintValue{radius}}
\fi
% JSaturne
\pstVerb{%
satLM satKA satHA satQ satP orbitalparameters
 /aS asat def
 aS /radius exch 1 E dup mul sub mul
     1 E LO LP sub cos mul add div def
 }%
 \ThreeDput{%
\psset{unit=0.35}
 \psplot[polarplot=true,plotpoints=361,linecolor=red]{LN }{LN 180 add}{%
 aS 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
 \psplot[polarplot=true,plotpoints=361,linestyle=dashed,linecolor=blue]{180 LN add}{LN 360 add}{%
 aS 1 E dup mul sub mul
 1 E x LP sub cos mul add div}%
\pnode(! radius LO cos mul radius LO sin mul){Saturne}
}%
\rput(Saturne){\psset{unit=0.1}\Saturne%
  \uput{1.7}[u](0,0){\footnotesize\textsf{Saturne}}}%
\ifPst@values
\rput(2.5,-4.25){\psPrintValue{LO}}
\rput(2.5,-4.75){\psPrintValue{LA}}
\rput(2.5,-5.25){\psPrintValue{radius}}
\fi
}
\ifPst@values
\rput(-4.5,-7.75){Mercure}
\rput(-2.5,-7.75){Venus}
\rput(-0.5,-7.75){Earth}
\rput(1.5,-7.75){Mars}
\rput(3.5,-7.75){Jupiter}
\rput(5.5,-7.75){Saturn}
\rput(-6.5,-8.42){longitude at $^\mathrm{o}$}
\rput(-6.5,-9.42){latitude at $^\mathrm{o}$}
\rput(-6.5,-10.42){distance at U.A.}
\fi
\end{pspicture}}}
%
\catcode`\@=\PstAtCode\relax
%
\endinput 