帮助创建复杂的图像

帮助创建复杂的图像

我是 latex tikz 的新手,我想将这张图片纳入我的作品中。我对 latex tikz 创建如此复杂图像的现有了解太少了。任何有关创建此图像的帮助都将不胜感激。

在此处输入图片描述

提前致谢。

答案1

这是一个建议。它利用了一些开发出来的技巧这里这里这里

\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}

在此处输入图片描述

请注意,尽管原则上您可以调整视图,但在这里您不能,因为我通过反复试验找到了一些角度(对于黄色半球)。

相关内容