0

I am new to latex tikz and I would like to include this image into my work. My existing knowledge of latex tikz for creating such a complex image is a too bit low. Any help in creating this image will highly appreciated.

enter image description here

Thanks in advance.

Maxey
  • 43
  • 2
    Start with https://tex.stackexchange.com/questions/235068/draw-a-hemisphere-or-just-a-segment-of-a-sphere, then draw one sphere and 3 hemispheres from the center out. – John Kormylo Oct 31 '18 at 11:53
  • 1
    Welcome to TeX.SE! Max, another Max has created this beautiful answer on hemispheres, maybe you want to check it out? –  Oct 31 '18 at 12:23
  • Still no luck. I have no idea how can I start to draw the sphere and 2 hemisphere. Kindly help me in designing the image. I tried the code but it's only the copy I can't figure out the coding scheme for put 3 hemispheres onto it. – Maxey Nov 04 '18 at 14:02

1 Answers1

4

Here is a proposal. It makes use of some tricks developed here, here and here.

\documentclass[tikz,border=3.14mm]{standalone}
\usepackage{tikz-3dplot}

\makeatletter

%along z axis % from https://tex.stackexchange.com/a/375604/121799
\define@key{z sphericalkeys}{radius}{\def\myradius{#1}}
\define@key{z sphericalkeys}{theta}{\def\mytheta{#1}}
\define@key{z sphericalkeys}{phi}{\def\myphi{#1}}
\tikzdeclarecoordinatesystem{z spherical}{% 
    \setkeys{z sphericalkeys}{#1}%
    \pgfpointxyz{\myradius*cos(\mytheta)*cos(\myphi)}{%
    \myradius*cos(\mytheta)*sin(\myphi)}{\myradius*sin(\mytheta)}
}
\tikzdeclarecoordinatesystem{z spherical visible}{% 
    \setkeys{z sphericalkeys}{#1}%
    \pgfmathsetmacro{\Xtest}{cos(90-\tdplotmaintheta)*cos(\tdplotmainphi-90)*cos(\mytheta)*cos(\myphi)
    +cos(90-\tdplotmaintheta)*sin(\tdplotmainphi-90)*cos(\mytheta)*sin(\myphi)
    +sin(90-\tdplotmaintheta)*sin(\mytheta)}
    % \Xtest is the projection of the coordinate on the normal vector of the visible plane
    \pgfmathsetmacro{\ntest}{ifthenelse(\Xtest<0,0,1)}
    \ifnum\ntest=0
      \pgfmathsetmacro{\myx}{\myradius*cos(\mytheta)*cos(\myphi)*\raarot
      +\myradius*cos(\mytheta)*sin(\myphi)*\rabrot+\myradius*sin(\mytheta*\racrot}
      \pgfmathsetmacro{\myy}{\myradius*cos(\mytheta)*cos(\myphi)*\rbarot
      +\myradius*cos(\mytheta)*sin(\myphi)*\rbbrot+\myradius*sin(\mytheta*\rbcrot}  
      \pgfpoint{\RadiusSphere*cos(atan2(\myy,\myx))*1cm}{\RadiusSphere*sin(atan2(\myy,\myx))*1cm}
    \else
      \pgfpointxyz{\myradius*cos(\mytheta)*cos(\myphi)}{%
      \myradius*cos(\mytheta)*sin(\myphi)}{\myradius*sin(\mytheta)}
    \fi
}

% from https://tex.stackexchange.com/a/127045/121799
\tikzset{use path/.code=\tikz@addmode{\pgfsyssoftpath@setcurrentpath#1}}
\makeatother
\begin{document}
\pgfmathsetmacro{\RadiusSphere}{4.5}

\begin{tikzpicture}
\path[use as bounding box] ({-1.2*\RadiusSphere},{-1.2*\RadiusSphere}) rectangle
({1.2*\RadiusSphere},{1.2*\RadiusSphere});
\tdplotsetmaincoords{70}{110}
\begin{scope}[tdplot_main_coords,samples=60,rotate=30]
\begin{scope} % cyan hemisphere
\shade[ball color=cyan,tdplot_screen_coords]  (0,0) circle (\RadiusSphere);
\filldraw[white]  plot[smooth,variable=\x,domain=0:360] 
(z spherical visible cs: radius=4.5,phi={00},theta={\x});
\path (z spherical cs: radius=4.5,phi={0},theta={120}) coordinate
(t) (z spherical cs: radius=4.5,phi={00},theta={-60}) coordinate (b);
\fill[white,tdplot_screen_coords] (t) -- (b) -- 
++ (2*\RadiusSphere,0) coordinate(aux) -- (aux |- t) ;
\fill[green!30!black]  plot[smooth,variable=\x,domain=0:360] 
(z spherical cs: radius=4.5,phi={00},theta={\x});
\end{scope}
\begin{scope} % yellow hemisphere
\pgfmathsetmacro{\RadiusSphere}{4}
\fill[yellow!60!orange] plot[smooth,variable=\x,domain=00:180,samples=101] 
(z spherical cs: radius=\RadiusSphere,phi={\x},theta={0}) --cycle;
\path[save path=\pathC] 
plot[smooth,variable=\x,domain=00:118,samples=101] 
(z spherical cs: radius=\RadiusSphere,phi={\x},theta={0})
-- plot[smooth,variable=\x,domain=00:-95,samples=31,tdplot_screen_coords] (\x:\RadiusSphere)
-- plot[smooth,variable=\x,domain=-75:0,samples=31,tdplot_main_coords] 
(z spherical cs: radius=\RadiusSphere,phi={0},theta={\x});
\clip[use path=\pathC];
\shade[ball color=yellow!60!orange,tdplot_screen_coords]  (0,0) circle (\RadiusSphere);
\end{scope}
\begin{scope}
\fill[gray] (0,0,0) -- plot[smooth,variable=\x,domain=90:0] 
(z spherical visible cs: radius=3.5,phi={90},theta={\x});
\end{scope}
\begin{scope}
\pgfmathsetmacro{\RadiusSphere}{3}
\draw[save path=\pathA] plot[smooth,variable=\x,domain=90:00] 
(z spherical visible cs: radius=\RadiusSphere,phi={0},theta={\x})
-- plot[smooth,variable=\x,domain=0:90] 
(z spherical visible cs: radius=\RadiusSphere,phi={\x},theta={0})
-- plot[smooth,variable=\x,domain=0:90] 
(z spherical visible cs: radius=\RadiusSphere,phi={90},theta={\x});
\clip[use path=\pathA];
\shade[ball color = orange,tdplot_screen_coords]  (0,0) circle (\RadiusSphere);
\end{scope}
\begin{scope}
\pgfmathsetmacro{\RadiusSphere}{3.5}
\path[save path=\pathB] 
plot[smooth,variable=\x,domain=90:00,samples=101] 
(z spherical visible cs: radius=\RadiusSphere,phi={90},theta={\x})
-- plot[smooth,variable=\x,domain=90:180] 
(z spherical visible cs: radius=\RadiusSphere,phi={\x},theta={0})
-- plot[smooth,variable=\x,domain=0:90] 
(z spherical visible cs: radius=\RadiusSphere,phi={180},theta={\x});
\clip[use path=\pathB];
\shade[ball color =gray!80,tdplot_screen_coords]  (0,0) circle (\RadiusSphere);
\end{scope}
\end{scope}
\draw[orange] (-1,2) node[circle,fill,inner sep=1pt]{} -- ++(135:1) -- ++(180:3);
\draw[orange] (225:4) node[circle,fill,inner sep=1pt]{} -- ++(225:1.5);
\draw[orange] (-45:3.5) node[circle,fill,inner sep=1pt]{} -- ++(-45:2);
\draw[orange] (1,3.1) node[circle,fill,inner sep=1pt]{} -- ++(45:1) -- ++(2.5,0);
\end{tikzpicture}
\end{document}

enter image description here

Note that, even though in principle you can adjust the view, here you can't because I found a few angle (for the yellow hemisphere) by trial and error.

  • @ marmot: Thanks for the kindness, it really worked for me and I appreciate your time. I have another image posted for which I'd kindly need some help too. – Maxey Nov 09 '18 at 11:51