Created
September 10, 2017 20:39
-
-
Save mcnees/43236335f3be3ed81b5abe9779517c80 to your computer and use it in GitHub Desktop.
Shaded hemisphere in perspective using PGF/TikZ
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass[crop=true, border=10pt]{standalone} | |
\usepackage{xcolor} | |
\usepackage{tikz} | |
\usetikzlibrary{arrows.meta} | |
% Some colors I like. The first six are modified versions of colors from | |
% the Gnome Project "Tango" palette. | |
\definecolor{plum}{rgb}{0.36078, 0.20784, 0.4} | |
\definecolor{chameleon}{rgb}{0.30588, 0.60392, 0.023529} | |
\definecolor{cornflower}{rgb}{0.12549, 0.29020, 0.52941} | |
\definecolor{scarlet}{rgb}{0.8, 0, 0} | |
\definecolor{brick}{rgb}{0.64314, 0, 0} | |
\definecolor{sunrise}{rgb}{0.80784, 0.36078, 0} | |
\definecolor{lightblue}{rgb}{0.15,0.35,0.75} | |
\definecolor{carolina}{RGB}{153, 186, 221} | |
% A custom arrowhead for use on x, y, z axes | |
\tikzstyle{axisarrow} = [-{Latex[inset=0pt,length=5pt]}] | |
\begin{document} | |
\begin{tikzpicture}[scale=1.2] | |
% Draw the background grid. | |
\draw [cornflower!20,step=0.25,thin] (-3,-3) grid (3,3); | |
\draw [cornflower!40,step=1.0,thin] (-3,-3) grid (3,3); | |
% The obscured part of the z-axis | |
\draw (0,0) -- (0,-3); | |
% Draw a shaded ball, but clip so only the lower half shows. | |
% The arc in the clipping region is the foreground part of the equator | |
\begin{scope} | |
\clip(-3,-3) -- (-3,0) -- (-2,0) arc (180:360:2cm and 0.6cm) -- (3,0) -- (3,-3) -- (-3,-3); | |
\shade[ball color=chameleon!60!white, opacity=0.70] (0,0) circle (2cm); | |
\end{scope} | |
% Draw the disc on top of the hemisphere. | |
\shade[shading=radial, inner color=chameleon!20!white, outer color=chameleon!60!white, opacity=0.70] (2,0) arc (0:360:2cm and 0.6cm); | |
% Outline the disk in black | |
\draw (2,0) arc (0:360:2cm and 0.6cm); | |
% Outline the hemisphere in black | |
\draw (-2,0) arc (180:360:2cm and 2cm); | |
% A dashed line and label indicating the radius | |
\draw [dashed] (0,0)--(2,0); | |
\node at (1.2,.2) {$R$}; | |
% The rest of the z-axis | |
\draw[axisarrow] (0,0) -- (0,3); | |
\node at (.2,2.8) {$z$}; | |
% The y-axis | |
\draw[axisarrow] (-2.5,1) -- (2.5,-1); | |
\node at (2.5,-1.2) {$y$}; | |
% The x-axis | |
\draw[axisarrow] (2.5,1) -- (-2.5,-1); | |
\node at (-2.5,-0.8) {$x$}; | |
\end{tikzpicture} | |
\end{document} |
Author
mcnees
commented
Sep 10, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment