# Draw death star

How to add the typical grid cells

(image modified from https://en.wikipedia.org/wiki/Death_Star) to the following sketch of the death star?

This is what I have so far

\documentclass{standalone}

\usepackage{tikz}

\begin{document}

\begin{tikzpicture}
\fill[ball color=gray!10!white,  shading=ball] (0,0) circle (1);
\shade[outer color=gray!10!white, inner color=gray,draw=gray!50!white] (-0.3,0.3) circle (0.35);

\fill[gray!50!white] (0,0) rectangle (0.2,-0.3);
\end{tikzpicture}

\end{document}


However the rectangle does not follow the shape of the grid and also does not have the shading.

• There are many questions already about drawing lines on a sphere. You need to explain what you mean, and not just write typical grid lines. tex.stackexchange.com/questions/269959/… tex.stackexchange.com/questions/226507/… – hpekristiansen May 4 at 12:29
• @hpekristiansen Thanks for the links, however I don't want to draw lines, I'd like to add the rectangular grid structures. I attached an image, maybe this will make it clearer. – Han Solo May 4 at 18:21
• You may be interested in this thread which explains how you can modify the shading. – marmot May 4 at 18:25
• @marmot Thank you very much for the link, this looks very helpful! I will read it carefully! – Han Solo May 4 at 18:27

Here is a quick proposal based on percusse's nice answer.

\documentclass[border=5mm]{standalone}
\usepackage{tikz}
% Compute distance difference (horizontally weighted twice). (50bp,50bp) is the center
65 sub dup mul exch                %Change the coordinate to move vertically
40 sub dup mul 0.5 mul add sqrt   %Change the coordinate to move horizontally
% In MATLAB notation : d=distance diff
% x=1.003^(-d^2)
dup mul neg 1.003 exch exp
% x is the only variable in the stack now but we need 3 values at the top of the stack
% so we duplicate these values putting new values in the stack.
dup % Duplicates with the current value and pushes the stack down (value of green)
dup % Duplicates with the current value and pushes the stack down (value of blue)
}
\makeatletter % https://tex.stackexchange.com/a/38995/121799
\tikzset{
use path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\makeatother
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}
\tdplotsetmaincoords{00}{00}
\pgfmathsetmacro{\mybeta}{acos(0.7)}
\pgfmathsetmacro{\myalpha}{acos(-0.3)/sin(\mybeta)}
\tdplotsetrotatedcoords{\myalpha}{\mybeta}{00}
\begin{scope}[tdplot_rotated_coords,canvas is xy plane at z=4]
\end{scope}
\clip[use path=\tmPath];
canvas={rotate=-100,xscale=-1}] (-75:2.5) circle
(2.5cm);
\end{tikzpicture}
\end{document}


Some pattern for CarLaTeX. There is a huge room for improvements. The pattern is drawn using sphere segments.

\documentclass[tikz,border=3.14mm]{standalone}
% Compute distance difference (horizontally weighted twice). (50bp,50bp) is the center
65 sub dup mul exch                %Change the coordinate to move vertically
40 sub dup mul 0.5 mul add sqrt   %Change the coordinate to move horizontally
% In MATLAB notation : d=distance diff
% x=1.003^(-d^2)
dup mul neg 1.003 exch exp
% x is the only variable in the stack now but we need 3 values at the top of the stack
% so we duplicate these values putting new values in the stack.
dup % Duplicates with the current value and pushes the stack down (value of green)
dup % Duplicates with the current value and pushes the stack down (value of blue)
}
\makeatletter % https://tex.stackexchange.com/a/38995/121799
\tikzset{
use path/.code={\pgfsyssoftpath@setcurrentpath{#1}}
}
\makeatother
\usepackage{tikz-3dplot}
\begin{document}
\begin{tikzpicture}[sphere segment/.style args={% from https://tex.stackexchange.com/a/482332/121799
phi from #1 to #2 and theta from #3 to #4 and radius #5}{insert path={%
plot[variable=\x,smooth,domain=#2:#1]
-- plot[variable=\x,smooth,domain=#3:#4]
--plot[variable=\x,smooth,domain=#1:#2]
-- plot[variable=\x,smooth,domain=#4:#3]
-- cycle}},death star/.cd,
\path[decorate,decoration={raise=1ex,text along path,text
align=center,text color=yellow,text={|\Huge\sffamily\bfseries|May the 4th be with you!}}] (180:1.1*\pgfkeysvalueof{/tikz/death star/radius})
\tdplotsetmaincoords{0}{00}
\pgfmathsetmacro{\mybeta}{acos(0.65)}
\pgfmathsetmacro{\myalpha}{acos(-0.2)/sin(\mybeta)}
\tdplotsetrotatedcoords{\myalpha}{\mybeta}{00}
\begin{scope}[tdplot_rotated_coords,canvas is xy plane at
\draw[thick,save path=\tmPath]
\end{scope}
\begin{scope}[x={(1cm,0)},y={(0,0)},z={(0,1cm)}]
\pgfmathsetseed{2}
\path[save path=\tmPathTwo] foreach \X [count=\XC] in {50,20,-40,-70} {
foreach \Y [count=\YC,evaluate=\YC as \ZC using {int(3.3*rnd)}]
in {-65,-45,-25,-5,15,35,55}
{\ifodd\ZC
[sphere segment=phi from {\Y} to {\Y+10} and theta from {\X} to {\X+20} and radius \pgfkeysvalueof{/tikz/death star/radius}]
\fi}}
[sphere segment=phi from {-90} to {90} and theta from {1} to {10} and radius \pgfkeysvalueof{/tikz/death star/radius},
sphere segment=phi from {-90} to {90} and theta from {-1} to {-10} and radius \pgfkeysvalueof{/tikz/death star/radius}];
\end{scope}
\begin{scope}
\clip[use path=\tmPathTwo];
\end{scope}
\clip[use path=\tmPath];