%% $Id: pst-solarsystem.tex 861 2024-02-02 08:15:14Z herbert $
%%
%% This is file `pst-solarsystem.tex',
%%
%% IMPORTANT NOTICE:
%%
%% Package `pst-solarsystem.tex'
%%
%% Manuel Luque <manuel.luque27@gmail.com>
%% Herbert Voss <hvoss@tug.org>
%%
%% 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.15}
\def\filedate{2024/02/02}
\message{`PSTSOLARSYSTEME' v\fileversion, \filedate}
%
\pstheader{pst-solarsystem.pro}
%
\edef\PstAtCode{\the\catcode`\@} \catcode`\@=11\relax
%
\pst@addfams{pst-solarsystem}

\def\SolarSystemLangEN{%
    \def\ps@@Mercury{Mercury}%
    \def\ps@@Venus{Venus}%
    \def\ps@@Earth{Earth}%
    \def\ps@@Mars{Mars}%
    \def\ps@@Jupiter{Jupiter}%
    \def\ps@@Saturn{Saturn}%
    \def\ps@@Longitude{longitude  at $^\mathrm{o}$}%
    \def\ps@@Latitude{latitude at $^\mathrm{o}$}%
    \def\ps@@Distance{distance in AU}%
}

\def\SolarSystemLangDE{%
    \def\ps@@Mercury{Merkur}%
    \def\ps@@Venus{Venus}%
    \def\ps@@Earth{Erde}%
    \def\ps@@Mars{Mars}%
    \def\ps@@Jupiter{Jupiter}%
    \def\ps@@Saturn{Saturn}%
    \def\ps@@Longitude{Längengrad $^\mathrm{o}$ }%
    \def\ps@@Latitude{Breitengrad $^\mathrm{o}$ }%
    \def\ps@@Distance{Entfernung in AU }%
}

\def\SolarSystemLangFR{%
    \def\ps@@Mercury{Mercure}%
    \def\ps@@Venus{V{\´e}nus}%
    \def\ps@@Earth{Terre}%
    \def\ps@@Mars{Mars}%
    \def\ps@@Jupiter{Jupiter}%
    \def\ps@@Saturn{Saturne}%
    \def\ps@@Longitude{longitude a $^\mathrm{o}$}%
    \def\ps@@Latitude{latitude  a $^\mathrm{o}$}%
    \def\ps@@Distance{distance en au }%
}
\let\SolarSystemLangen\SolarSystemLangEN
\let\SolarSystemLangde\SolarSystemLangDE
\let\SolarSystemLangfr\SolarSystemLangFR

\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}}
\define@key[psset]{pst-solarsystem}{language}[EN]{\@nameuse{SolarSystemLang#1}}
%
\psset{Day=\number\day,Month=\number\month,Year=\number\year,Hour=12,Minute=0,Second=0,
	language=EN}
%% === show the results ---------------------
%\newif\ifPst@solar@values
%\define@key[psset]{pst-solarsystem}{solarValues}{\@nameuse{Pst@solar@values#1}\ifPst@solar@values true \else false \fi}
\define@boolkey[psset]{pst-solarsystem}[Pst@]{solarValues}[true]{}
\psset[pst-solarsystem]{solarValues=true}


\newpsstyle{planets}{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\Saturn{%
  \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@keep@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=planets,gradbegin=black,GradientPos={(0.01,0.01)}]{0.02}
    \uput[u](0,0){\footnotesize\textsf{\ps@@Mercury}}}
  \ifPst@solarValues
    \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=planets,gradbegin={[HTML]{6F2D0A}},GradientPos={(0.03,0.03)}]{0.051}%
    \uput{0.07}[u](0,0){\footnotesize\textsf{\ps@@Venus}}}
  \ifPst@solarValues
    \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=planets,gradbegin=blue,GradientPos={(0.013,0.03)}]{0.0536}%
  \uput{0.08}[u](0,0){\footnotesize\textsf{\ps@@Earth}}}%
  \ifPst@solarValues
    \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=planets,gradbegin=red,GradientPos={(0.01,0.01)}]{0.02857}
    \uput[u](0,0){\footnotesize\textsf{\ps@@Mars}}}%
  \ifPst@solarValues
    \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{\ps@@Jupiter}}}%
  \ifPst@solarValues
    \rput(1.5,-4.25){\psPrintValue{LO}}%
    \rput(1.5,-4.75){\psPrintValue{LA}}%
    \rput(1.5,-5.25){\psPrintValue{radius}}%
  \fi
% JSaturn
  \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){Saturn}%
  }%
  \rput(Saturn){\psset{unit=0.1}\Saturn%
    \uput{1.7}[u](0,0){\footnotesize\textsf{\ps@@Saturn}}}%
  \ifPst@solarValues
    \rput(2.5,-4.25){\psPrintValue{LO}}%
    \rput(2.5,-4.75){\psPrintValue{LA}}%
    \rput(2.5,-5.25){\psPrintValue{radius}}%
  \fi
  }
  \use@par
  \ifPst@solarValues
    \rput(-4.5,-7.75){\ps@@Mercury}%
    \rput(-2.5,-7.75){\ps@@Venus}%
    \rput(-0.5,-7.75){\ps@@Earth}%
    \rput(1.5,-7.75){\ps@@Mars}%
    \rput(3.5,-7.75){\ps@@Jupiter}%
    \rput(5.5,-7.75){\ps@@Saturn}%
    \rput[r](-5.5,-8.42){\ps@@Longitude}%
    \rput[r](-5.5,-9.42){\ps@@Latitude}%
    \rput[r](-5.5,-10.42){\ps@@Distance}%
   \fi
\end{pspicture}}}
%
\catcode`\@=\PstAtCode\relax
%
\endinput 