summaryrefslogtreecommitdiff
path: root/graphics/pgf/contrib/tikz-planets/planets.sty
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/pgf/contrib/tikz-planets/planets.sty')
-rw-r--r--graphics/pgf/contrib/tikz-planets/planets.sty328
1 files changed, 248 insertions, 80 deletions
diff --git a/graphics/pgf/contrib/tikz-planets/planets.sty b/graphics/pgf/contrib/tikz-planets/planets.sty
index 6fcc37304e..a0717ad262 100644
--- a/graphics/pgf/contrib/tikz-planets/planets.sty
+++ b/graphics/pgf/contrib/tikz-planets/planets.sty
@@ -1,6 +1,19 @@
-\ProvidesPackage{planets}
+% Package tikz-planets -- illustrate celestial mechanics with TikZ
+% Version 1.0.2
+
+% Isabelle M. Santos
+% This work is licensed under the Creative Commons Attribution-ShareAlike 4.0 International License.
+% To view a copy of this license, visit http://creativecommons.org/licenses/by-sa/4.0/
+
+% This program is distributed in the hope that it will be useful,
+% but WITHOUT ANY WARRANTY; without even the implied warranty of
+% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+\ProvidesPackage{planets}[2020/04/19 v1.0.2 celestial mechanics with Tikz]
\RequirePackage{tikz}
+\usetikzlibrary{decorations.pathmorphing}
+
\RequirePackage{xstring}
% Colors %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -18,6 +31,8 @@
\definecolor{neptune4}{rgb}{.12, .56, 1}
\definecolor{neptune5}{rgb}{.42, .35, .8}
\definecolor{neptune_white}{rgb}{94, 1, 1}
+\definecolor{pluto1}{rgb}{.82, .77, .71}
+\definecolor{pluto2}{rgb}{.24, .18, .11}
\definecolor{brownish}{rgb}{.7, .58, .42}
\definecolor{wheat}{rgb}{.96, .87, .7}
@@ -30,27 +45,38 @@
% Keys %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newif\ifrotation
+\newif\ifequator
+\newif\ifaxis
\newif\ifretrograde
-\newif\ifring
+\newif\ifrings
\RequirePackage{pgfkeys}
\pgfkeys{
/planet/.is family, /planet,
- surface/.estore in = \surface,
- tilt/.estore in = \tilt,
- phase/.estore in = \phase,
+ surface/.estore in = \surfacename,
+ tilt/.estore in = \axialtilt,
+ phase/.estore in = \planetphase,
rotation/.is if = rotation,
+ equator/.is if = equator,
+ axis/.is if = axis,
retrograde/.is if = retrograde,
+ rings/.is if = rings,
+ ring/.estore in = \ringradius,
color/.estore in = \mycolor,
- centerx/.estore in = \centerx,
- centery/.estore in = \centery,
- scale/.estore in = \scale,
+ center/.code={\pgfkeyssetvalue{center}{#1}\pgfkeysgetvalue{center}{\planetcenter}},
+ centerx/.estore in = \planetcenterx,
+ centery/.estore in = \planetcentery,
+ scale/.estore in = \planetscale,
default/.style = {
surface = none,
tilt = 0,
phase = full,
rotation = false,
+ equator = false,
+ axis = false,
retrograde = false,
+ rings = false,
+ ring =,
color = cyan,
centerx = 0,
centery = 0,
@@ -69,8 +95,8 @@
}
\newcommand{\addrotation}{%
- % equator arrow
\ifretrograde
+ % equator arrow
\draw [->, very thick] (0, 0) -- (-0.4, 0);
% axis arrow
@@ -84,7 +110,7 @@
\fi
}
-\newcommand{\addphase}[1]{%
+\newcommand{\addsurfacephase}[1]{%
\IfEqCase{#1}{%
{new}{\fill [opacity=0.6, black] (0, 0) circle (1);}
{first half}{\fill [opacity=0.6, black] (90:1) arc (90:270:1) -- cycle;}
@@ -99,13 +125,78 @@
}
}
+\newcommand{\drawringpath}[1]{
+ \path[#1, even odd rule]
+ (0, 0) circle [x radius = 1.3, y radius = .13]
+ (0, 0) circle [x radius = 1.7, y radius = .17]
+ (0, 0) circle [x radius = 1.75, y radius = .175]
+ (0, 0) circle [x radius = 2.1, y radius = .21];
+}
+\newcommand{\addringphase}[1]{%
+ \IfEqCase{#1}{%
+ {new}{
+ \clip (-.85, -.25) -- (.85, -.25) -- (1, 0) -- (-1, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {first half}{
+ \clip (-1, -.1) -- (-1, .1) -- (-2.2, 0) -- (-2.2, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {last half}{
+ \clip (1, -.1) -- (1, .1) -- (2.2, 0) -- (2.2, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {first crescent}{
+ \clip (-1.1, 0) -- (-1.5, -.22) -- (0, -.22) -- (1, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {last crescent}{
+ \clip (1.1, 0) -- (1.5, -.22) -- (0, -.22) -- (-1, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {waxing gibbous}{
+ \clip (-1.2, 0) -- (-1.5, .22) -- (0, .22) -- (1, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {waning gibbous}{
+ \clip (1.2, 0) -- (1.5, .22) -- (0, .22) -- (-1, 0) -- cycle;
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {top half}{
+ %pass
+ }
+ {bottom half}{
+ \drawringpath{inner color=black, outer color=black, opacity=.6}
+ }
+ {full}{
+ %pass
+ }
+ }
+}
+\newcommand{\addrings}{%
+ \drawringpath{inner color=yellowish!90!black,outer color=yellowish!90!black}
+}
+
+\newcommand{\addthinring}[1]{%
+
+ \def\a{#1}
+ \def\b{\a/7}
+ \def\x{ sqrt( (\a*\a-\b*\b*\a*\a) / (\a*\a-\b*\b) ) }
+ \def\y{ sqrt( 1 - (\a*\a-\b*\b*\a*\a) / (\a*\a-\b*\b) ) }
+
+ \begin{scope}
+ \clip (-{\x}, 0) -- ({\x}, 0) -- ({\x}, 1) --({{\a}}, 1) -- ({\a}, -1) -- (-{\a}, -1) -- (-{\a}, 1) -- (-{\x}, 1) -- (-{\x}, 0) -- cycle;
+ \draw[gray] (0, 0) circle ({\a} and {\b});
+ \end{scope}
+}
+
% Surfaces %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand{\sun}{%
+\newcommand{\sunsurface}{%
\draw [yellow!50, ultra thick, fill=yellow!85!red] (0, 0) circle (1);
}
-\newcommand{\mercury}{%
+\newcommand{\mercurysurface}{%
\draw [gray!70!black, ultra thick, fill=gray] (0, 0) circle (1);
\draw [mercury_crater_edge, fill=mercury_crater] ( 0.5 , 0.56 ) circle ( 0.094 );
@@ -124,10 +215,10 @@
\draw [mercury_crater_edge, fill=mercury_crater] ( 0.61 , -0.14 ) circle ( 0.03 );
\draw [mercury_crater_edge, fill=mercury_crater] ( 0.7 , -0.16 ) circle ( 0.01 );
- \draw [mercury_crater_edge, fill=mercury_crater] ( -0.32 , -0.29 ) circle ( 0.02 );
\draw [mercury_crater_edge, fill=mercury_crater] ( -0.47 , -0.41 ) circle ( 0.08 );
\draw [mercury_crater_edge, fill=mercury_crater] ( -0.2 , -0.87 ) circle ( 0.07 );
\draw [mercury_crater_edge, fill=mercury_crater] ( -0.78 , -0.17 ) circle ( 0.03 );
+ \draw [mercury_crater_edge, fill=mercury_crater] ( -0.32 , -0.29 ) circle ( 0.02 );
\draw [mercury_crater_edge, fill=mercury_crater] ( -0.57 , -0.66 ) circle ( 0.02 );
\draw [mercury_crater_edge, fill=mercury_crater] ( -0.38 , 0.49 ) circle ( 0.1 );
@@ -145,11 +236,11 @@
color(1.7cm)=(venus2!90!black);
color(1.9cm)=(venus1)
}
-\newcommand{\venus}{%
+\newcommand{\venussurface}{%
\draw [color=brown!40, shading=Venus, ultra thick] (0, 0) circle (1);
}
-\newcommand{\earth}{
+\newcommand{\earthsurface}{
% Globe
\draw [fill=cyan] (0,0) circle (1);
@@ -168,11 +259,11 @@
\draw [neptune3, ultra thick] (0,0) circle (1);
}
-\newcommand{\moon}{%
- % Disque
+\newcommand{\moonsurface}{%
+ % Disc
\draw [fill=gray!30] (0, 0) circle (1);
- % Crateres
+ % Craters
\draw [gray!60, ultra thick, fill=gray!55] (-.55, .2) circle (.4);
\draw [gray!65, ultra thick, fill=gray!60] (-.1, .65) circle (.3);
@@ -183,18 +274,18 @@
\draw [gray!55, ultra thick, fill=gray!50] (.2, -.2) circle (.2);
- % Petits crateres
+ % Small craters
\draw [gray, very thick, fill=gray!80] (.1, -.7) circle (.05);
\draw [gray, very thick, fill=gray!80] (.8, -.2) circle (.05);
\draw [gray, very thick, fill=gray!80] (-.3, .7) circle (.05);
\draw [gray, very thick, fill=gray!80] (-.1, .6) circle (.05);
\draw [gray, very thick, fill=gray!80] (-.2, 0) circle (.05);
- % Bord
+ % Edge
\draw [gray!40, ultra thick] (0, 0) circle (1);
}
-\newcommand{\mars}{%
+\newcommand{\marssurface}{%
\draw [fill=red!50!brown] (0, 0) circle (1);
% Poles
@@ -205,6 +296,25 @@
\draw [color=red!60!black, ultra thick] (0, 0) circle (1);
}
+\newcommand{\jupitersurface}{
+ \draw[color=brown!60, fill=brown!20, ultra thick] (0, 0) circle (1);
+
+ %Stripes
+ \clip (0, 0) circle (1);
+ \fill [color=brown!70, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (-1.2, -.25) -- (1.1, -.25) -- (1.1, .25) -- (-1.2, .25) -- cycle;
+
+ \fill [color=brown!70, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (130:1) -- (50:1) -- (50:2) arc (50:130:2) -- cycle;
+ \fill [color=brown!70, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (130:-1) -- (50:-1) -- (50:-2) arc (50:130:-2) -- cycle;
+
+ \fill [color=brown!30, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (-1.2, -.03) -- (1.1, -.03) -- (1.1, .03) -- (-1.2, .03) -- cycle;
+
+ \fill [color=brown!50, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (-1.2, .5) -- (1.1, .5) -- (1.1, .54) -- (-1.2, .54) -- cycle;
+ \fill [color=brown!50, decorate, decoration={snake, segment length=5, amplitude=.2, post length=0}] (-1.2, -.5) -- (1.1, -.5) -- (1.1, -.54) -- (-1.2, -.54) -- cycle;
+
+ % Spot
+ \fill[color=red!50!brown] (-.4, -.3) circle (.18 and .14);
+}
+
\pgfdeclareverticalshading{Jupiter}{2cm}{
color(0cm)=(brownish);
color(0.2cm)=(wheat!55!sienna);
@@ -219,52 +329,36 @@
color(1.7cm)=(white);
color(1.9cm)=(wheat!90!black)
}
-\newcommand{\jupiter}{%
- \draw [color=brown!80!yellow, shading=Jupiter, ultra thick] (0, 0) circle (1);
+\newcommand{\shadedjupitersurface}{%
+ \draw [color=brown!50, shading=Jupiter, ultra thick] (0, 0) circle (1);
% Spot
\draw [brownish!50!orangish, thick, fill=orange!50!red] (-0.4, -0.25) circle (.13 and .1);
}
-\pgfdeclareverticalshading{SaturnBottom}{2cm}{
+\pgfdeclareverticalshading{Saturn}{2cm}{
color(0cm)=(whiteish!55!black);
- color(0.2cm)=(greenish!50);
- color(0.3cm)=(whiteish);
- color(0.5cm)=(greenish);
- color(0.6cm)=(whiteish!50!orangish);
- color(1.2cm)=(greenish);
- color(1.4cm)=(wheat!90!black);
- color(1.7cm)=(wheat);
- color(1.9cm)=(pinkish)
-}
-\pgfdeclareverticalshading{SaturnTop}{2cm}{
- color(0cm)=(pinkish);
- color(.1cm)=(wheat);
- color(.3cm)=(wheat!90!black);
- color(.6cm)=(greenish);
- color(1cm)=(whiteish!50!orangish);
- color(1.4cm)=(yellowish!70!orangish);
- color(1.8cm)=(whiteish!55!sienna)
+ color(0.1cm)=(greenish!50);
+ color(0.15cm)=(whiteish);
+ color(0.25cm)=(greenish);
+ color(0.3cm)=(whiteish!50!orangish);
+ color(0.6cm)=(greenish);
+ color(0.7cm)=(wheat!90!black);
+ color(0.85cm)=(wheat);
+ color(0.95cm)=(pinkish);
+ color(1cm)=(pinkish);
+ color(1.1cm)=(wheat);
+ color(1.2cm)=(wheat!90!black);
+ color(1.3cm)=(greenish);
+ color(1.5cm)=(whiteish!50!orangish);
+ color(1.7cm)=(yellowish!70!orangish);
+ color(1.9cm)=(whiteish!55!sienna)
}
-\newcommand{\saturn}{%
- % Top half
- \fill [color=yellowish, shading=SaturnTop, ultra thick] (0:1) arc (0:180:1) -- cycle;
- \draw [yellowish, ultra thick] (0:1) arc (0:180:1);
-
- % Ring
- \path[inner color=black,outer color=yellowish,even odd rule]
- (0, 0) circle [x radius = 1.5, y radius = .25]
- (0, 0) circle [x radius = 1.7, y radius = .3]
- (0, 0) circle [x radius = 1.75, y radius = .33]
- (0, 0) circle [x radius = 1.95, y radius = .38];
-
- % Bottom half
- \fill [color=yellowish, shading=SaturnBottom, ultra thick] (180:1) arc (180:360:1) -- cycle;
- \draw [yellowish, ultra thick] (180:1) arc (180:360:1);
-
+\newcommand{\saturnsurface}{%
+ \draw [color=yellowish, shading=Saturn, ultra thick, shading angle=\axialtilt] (0, 0) circle (1);
}
-\newcommand{\uranus}{%
+\newcommand{\uranussurface}{%
\draw [color=uranus_gray, fill=uranus_blue, ultra thick] (0, 0) circle (1);
}
@@ -277,50 +371,124 @@
color(1.6cm)=(neptune4);
color(1.9cm)=(neptune5)
}
-\newcommand{\neptune}{%
- \draw [color=blue!40, shading=Neptune, ultra thick] (0, 0) circle (1);
+\newcommand{\neptunesurface}{%
+ \draw [color=blue!40, shading=Neptune, ultra thick, shading angle=\axialtilt] (0, 0) circle (1);
+}
+
+\pgfdeclareverticalshading{Pluto}{2cm}{
+ color(0cm)=(pluto1);
+ color(.4cm)=(pluto2);
+ color(.7cm)=(pluto2);
+ color(1.2cm)=(pluto1);
+ color(1.9cm)=(pluto1)
+}
+\newcommand{\plutosurface}{%
+ \fill [shading=Pluto, shading angle=\axialtilt] (0, 0) circle (1);
+
+ \fill [pluto1, thick, domain=-150:100, samples=50]
+ plot ({ .67*sin(\x) * sin(\x) * sin(\x) + .5 },
+ { .65 * cos(\x) - .2 * cos(2*\x) - .1 * cos(3*\x) - .05 * cos(4*\x) - .4 } );
+
+ \draw [color=pluto2!50, ultra thick] (0,0) circle (1);
+}
+
+\newcommand{\genericsurface}{
+ \draw [color=white!50!\mycolor, fill=\mycolor, ultra thick] (0, 0) circle (1);
}
\newcommand{\addsurface}[1]{%
\IfEqCase{#1}{%
- {earth}{\earth}
- {moon}{\moon}
- {sun}{\sun}
- {mars}{\mars}
- {mercury}{\mercury}
- {venus}{\venus}
- {jupiter}{\jupiter}
- {saturn}{\saturn}
- {uranus}{\uranus}
- {neptune}{\neptune}
- {none}{}
+ {earth}{\earthsurface}
+ {moon}{\moonsurface}
+ {sun}{\sunsurface}
+ {mars}{\marssurface}
+ {mercury}{\mercurysurface}
+ {venus}{\venussurface}
+ {jupiter}{\jupitersurface}
+ {shadedjupiter}{\shadedjupitersurface}
+ {saturn}{\saturnsurface}
+ {uranus}{\uranussurface}
+ {neptune}{\neptunesurface}
+ {pluto}{\plutosurface}
+ {none}{\genericsurface}
}
}
% Main command %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand{\planet}[1][]{%
+\newcommand{\planet}[1][]{\begingroup%
\pgfkeys{/planet, default, #1}
- \begin{scope}[shift = {(\centerx, \centery)}, scale = \scale]
+ \pgfkeysifdefined{center}{%if
+ % pass
+ }{%else
+ \def\planetcenter{(\planetcenterx, \planetcentery)}
+ }
- % Circle %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
- \draw [color=white!50!\mycolor, ultra thick, fill=\mycolor] (0, 0) circle (1);
+ \IfStrEqCase{\surfacename}{{saturn}{\ringstrue}}
- \begin{scope}[rotate=\tilt]
- \addsurface{\surface}
- \end{scope}
+ \begin{scope}[shift = \planetcenter, scale = \planetscale]
+
+ \ifrings
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \begin{scope}[rotate=\axialtilt]% bottom half
+ \clip (0, 0) circle (1);
+ \addsurface{\surfacename}
+ \end{scope}
+ \begin{scope}
+ \addsurfacephase{\planetphase}
+ \end{scope}
+ \begin{scope}[rotate=\axialtilt]
+ \addrings
+ \addringphase{\planetphase}
+ \end{scope}
+ \begin{scope}[rotate=\axialtilt]% top half
+ \clip (-1, 0) rectangle (1, 1);
+ \clip (0, 0) circle (1);
+ \addsurface{\surfacename}
+ \end{scope}
+ \begin{scope}
+ \clip (\axialtilt : -1.1) -- (\axialtilt : 1.1) -- (1.1, 1.1) -- (-1.1, 1.1) -- cycle;
+ \addsurfacephase{\planetphase}
+ \end{scope}
+ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+ \else
+ \begin{scope}[rotate=\axialtilt]
+ \clip (0, 0) circle (1);
+ \addsurface{\surfacename}
+ \end{scope}
+ \addsurfacephase{\planetphase}
+ \fi
\ifrotation
- \begin{scope}[rotate=\tilt]
+ \begin{scope}[rotate=\axialtilt]
\addaxis
\addequator
\addrotation
\end{scope}
\fi
- \addphase{\phase}
+ \ifequator
+ \begin{scope}[rotate=\axialtilt]
+ \addequator
+ \end{scope}
+ \fi
+
+ \ifaxis
+ \begin{scope}[rotate=\axialtilt]
+ \addaxis
+ \end{scope}
+ \fi
+
+ \IfStrEq{\ringradius}{}{%
+ %pass
+ }{%
+ \begin{scope}[rotate=\axialtilt]
+ \addthinring{\ringradius}
+ \end{scope}
+ }%
\end{scope}
+ \endgroup
}